|
4 | 4 | #[cfg(feature = "chrono")] |
5 | 5 | use chrono::{TimeZone, Utc}; |
6 | 6 |
|
| 7 | +use crate::{ZipDateTime, ZipDateTimeBuilder}; |
| 8 | + |
7 | 9 | #[test] |
8 | 10 | #[cfg(feature = "chrono")] |
9 | | -fn date_conversion_test() { |
| 11 | +fn date_conversion_test_chrono() { |
10 | 12 | let original_dt = Utc.timestamp_opt(1666544102, 0).unwrap(); |
11 | 13 | let zip_dt = crate::ZipDateTime::from_chrono(&original_dt); |
12 | 14 | let result_dt = zip_dt.as_chrono().single().expect("expected single unique result"); |
13 | 15 | assert_eq!(result_dt, original_dt); |
14 | 16 | } |
| 17 | + |
| 18 | +#[test] |
| 19 | +fn date_conversion_test() { |
| 20 | + let year = 2000; |
| 21 | + let month = 9; |
| 22 | + let day = 8; |
| 23 | + let hour = 7; |
| 24 | + let minute = 5; |
| 25 | + let second = 4; |
| 26 | + |
| 27 | + let mut builder = ZipDateTimeBuilder::new(); |
| 28 | + |
| 29 | + builder = builder.year(year); |
| 30 | + builder = builder.month(month); |
| 31 | + builder = builder.day(day); |
| 32 | + builder = builder.hour(hour); |
| 33 | + builder = builder.minute(minute); |
| 34 | + builder = builder.second(second); |
| 35 | + |
| 36 | + let built = builder.build(); |
| 37 | + |
| 38 | + assert_eq!(year, built.year()); |
| 39 | + assert_eq!(month, built.month()); |
| 40 | + assert_eq!(day, built.day()); |
| 41 | + assert_eq!(hour, built.hour()); |
| 42 | + assert_eq!(minute, built.minute()); |
| 43 | + assert_eq!(second, built.second()); |
| 44 | +} |
0 commit comments