summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-12-20 12:20:22 +0100
committerGitHub <noreply@github.com>2019-12-20 12:20:22 +0100
commit38ae919c11cc596fa927b2d8bd95b828a2e8045b (patch)
tree6afce4065a9928b327c6da7d2e2176da247fe492
parentdb2fdf0c1f6f611bd0a8e574c4a455b0d74b3eca (diff)
parent4bbae9b4340c273405023b9a4016211c5fce1576 (diff)
Merge pull request #7 from matthiasbeyer/fix-icaltime-from-ints-bug
Fix icaltime from ints bug
-rw-r--r--src/time.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/time.rs b/src/time.rs
index 2fe4a33..28a94a1 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -35,6 +35,7 @@ impl IcalTime {
is_daylight: 0,
zone: ::std::ptr::null(),
};
+ let time = unsafe { ical::icaltime_normalize(time) };
IcalTime { time }
}
@@ -45,6 +46,8 @@ impl IcalTime {
time.second = second;
time.is_date = 0;
+ let time = unsafe { ical::icaltime_normalize(time) };
+
IcalTime { time }
}
@@ -299,4 +302,34 @@ mod tests {
let time = IcalTime::utc();
assert_eq!("20130102T010203Z", time.succ().to_string());
}
+
+ #[test]
+ fn test_invalid_month() {
+ let time = IcalTime::floating_ymd(2000, 13, 1);
+ assert_eq!("20010101", time.to_string());
+ }
+
+ #[test]
+ fn test_invalid_day() {
+ let time = IcalTime::floating_ymd(2000, 12, 32);
+ assert_eq!("20010101", time.to_string());
+ }
+
+ #[test]
+ fn test_invalid_hour() {
+ let time = IcalTime::floating_ymd(2000, 12, 31).and_hms(25, 0, 0);
+ assert_eq!("20010101T010000", time.to_string());
+ }
+
+ #[test]
+ fn test_invalid_minute() {
+ let time = IcalTime::floating_ymd(2000, 12, 31).and_hms(24, 61, 0);
+ assert_eq!("20010101T010100", time.to_string());
+ }
+
+ #[test]
+ fn test_invalid_second() {
+ let time = IcalTime::floating_ymd(2000, 12, 31).and_hms(24, 60, 61);
+ assert_eq!("20010101T010101", time.to_string());
+ }
}