Skip to content

Commit

Permalink
Add some more tests to from_timestamp_(millis|micros)
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Apr 26, 2023
1 parent 84bbea5 commit a419c4b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/naive/datetime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ fn test_datetime_from_timestamp_millis() {
(1662921288123, "2022-09-11 18:34:48.123000000"),
(1662921287890, "2022-09-11 18:34:47.890000000"),
(-2208936075000, "1900-01-01 14:38:45.000000000"),
(-1, "1969-12-31 23:59:59.999000000"),
(0, "1970-01-01 00:00:00.000000000"),
(1, "1970-01-01 00:00:00.001000000"),
(998, "1970-01-01 00:00:00.998000000"),
(999, "1970-01-01 00:00:00.999000000"),
(1000, "1970-01-01 00:00:01.000000000"),
(1001, "1970-01-01 00:00:01.001000000"),
(1002, "1970-01-01 00:00:01.002000000"),
(999_998, "1970-01-01 00:16:39.998000000"),
(999_999, "1970-01-01 00:16:39.999000000"),
(1_000_000, "1970-01-01 00:16:40.000000000"),
(1_000_001, "1970-01-01 00:16:40.001000000"),
(1_000_002, "1970-01-01 00:16:40.002000000"),
(119731017000, "1973-10-17 18:36:57.000000000"),
(1234567890000, "2009-02-13 23:31:30.000000000"),
(2034061609000, "2034-06-16 09:06:49.000000000"),
Expand Down Expand Up @@ -48,7 +60,19 @@ fn test_datetime_from_timestamp_micros() {
(1662921288123456, "2022-09-11 18:34:48.123456000"),
(1662921287890000, "2022-09-11 18:34:47.890000000"),
(-2208936075000000, "1900-01-01 14:38:45.000000000"),
(-1, "1969-12-31 23:59:59.999999000"),
(0, "1970-01-01 00:00:00.000000000"),
(1, "1970-01-01 00:00:00.000001000"),
(998, "1970-01-01 00:00:00.000998000"),
(999, "1970-01-01 00:00:00.000999000"),
(1000, "1970-01-01 00:00:00.001000000"),
(1001, "1970-01-01 00:00:00.001001000"),
(1002, "1970-01-01 00:00:00.001002000"),
(999_998, "1970-01-01 00:00:00.999998000"),
(999_999, "1970-01-01 00:00:00.999999000"),
(1_000_000, "1970-01-01 00:00:01.000000000"),
(1_000_001, "1970-01-01 00:00:01.000001000"),
(1_000_002, "1970-01-01 00:00:01.000002000"),
(119731017000000, "1973-10-17 18:36:57.000000000"),
(1234567890000000, "2009-02-13 23:31:30.000000000"),
(2034061609000000, "2034-06-16 09:06:49.000000000"),
Expand Down Expand Up @@ -77,6 +101,18 @@ fn test_datetime_from_timestamp_micros() {
);
}
}
#[test]
fn test_datetime_from_timestamp_issue934() {
let min_utc = crate::DateTime::<Utc>::MIN_UTC;
assert_eq!(
NaiveDateTime::from_timestamp_millis(min_utc.timestamp_millis()).unwrap(),
min_utc.naive_utc()
);
assert_eq!(
NaiveDateTime::from_timestamp_micros(min_utc.timestamp_micros()).unwrap(),
min_utc.naive_utc()
);
}

#[test]
fn test_datetime_from_timestamp() {
Expand Down

0 comments on commit a419c4b

Please sign in to comment.