summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/time.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/time.rs b/src/time.rs
index 49b7f4a..f40ded3 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -42,6 +42,7 @@ impl IcalTime {
is_daylight: 0,
zone: ::std::ptr::null(),
};
+ let time = unsafe { ical::icaltime_normalize(time) };
IcalTime { time }
}
@@ -54,6 +55,8 @@ impl IcalTime {
time.second = second;
time.is_date = 0;
+ let time = unsafe { ical::icaltime_normalize(time) };
+
IcalTime { time }
}
@@ -316,4 +319,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());
+ }
}