| 1 | // Copyright (c) 2022 Harry [Majored] [[email protected]] |
| 2 | // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE) |
| 3 | |
| 4 | #[cfg(feature = "chrono")] |
| 5 | use chronorust-analyzer cargo chrono 0.4.37 crate/::{TimeZonerust-analyzer cargo chrono 0.4.37 offset/TimeZone#, Utcrust-analyzer cargo chrono 0.4.37 offset/utc/Utc#}; |
| 6 | |
| 7 | use craterust-analyzer cargo async_zip 0.0.18 crate/::ZipDateTimeBuilderrust-analyzer cargo async_zip 0.0.18 date/builder/ZipDateTimeBuilder#; |
| 8 | |
| 9 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 10 | #[cfg(feature = "chrono")] |
| 11 | fn date_conversion_test_chronorust-analyzer cargo async_zip 0.0.18 tests/spec/date/date_conversion_test_chrono().() { |
| 12 | let original_dt = Utcrust-analyzer cargo chrono 0.4.37 offset/utc/Utc#.timestamp_optrust-analyzer cargo chrono 0.4.37 offset/TimeZone#timestamp_opt().(1666544102, 0).unwraprust-analyzer cargo chrono 0.4.37 offset/impl#[`LocalResult<T>`]unwrap().(); |
| 13 | let zip_dt = craterust-analyzer cargo async_zip 0.0.18 crate/::ZipDateTimerust-analyzer cargo async_zip 0.0.18 date/ZipDateTime#::from_chronorust-analyzer cargo async_zip 0.0.18 date/impl#[ZipDateTime]from_chrono().(&original_dt); |
| 14 | let result_dt = zip_dt.as_chronorust-analyzer cargo async_zip 0.0.18 date/impl#[ZipDateTime]as_chrono().().singlerust-analyzer cargo chrono 0.4.37 offset/impl#[`LocalResult<T>`]single().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("expected single unique result"); |
| 15 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result_dt, original_dt); |
| 16 | } |
| 17 | |
| 18 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 19 | fn date_conversion_testrust-analyzer cargo async_zip 0.0.18 tests/spec/date/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 = ZipDateTimeBuilderrust-analyzer cargo async_zip 0.0.18 date/builder/ZipDateTimeBuilder#::newrust-analyzer cargo async_zip 0.0.18 date/builder/impl#[ZipDateTimeBuilder]new().(); |
| 28 | |
| 29 | builder = builder.yearrust-analyzer cargo async_zip 0.0.18 date/builder/impl#[ZipDateTimeBuilder]year().(year); |
| 30 | builder = builder.monthrust-analyzer cargo async_zip 0.0.18 date/builder/impl#[ZipDateTimeBuilder]month().(month); |
| 31 | builder = builder.dayrust-analyzer cargo async_zip 0.0.18 date/builder/impl#[ZipDateTimeBuilder]day().(day); |
| 32 | builder = builder.hourrust-analyzer cargo async_zip 0.0.18 date/builder/impl#[ZipDateTimeBuilder]hour().(hour); |
| 33 | builder = builder.minuterust-analyzer cargo async_zip 0.0.18 date/builder/impl#[ZipDateTimeBuilder]minute().(minute); |
| 34 | builder = builder.secondrust-analyzer cargo async_zip 0.0.18 date/builder/impl#[ZipDateTimeBuilder]second().(second); |
| 35 | |
| 36 | let built = builder.buildrust-analyzer cargo async_zip 0.0.18 date/builder/impl#[ZipDateTimeBuilder]build().(); |
| 37 | |
| 38 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(year, built.yearrust-analyzer cargo async_zip 0.0.18 date/impl#[ZipDateTime]year().()); |
| 39 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(month, built.monthrust-analyzer cargo async_zip 0.0.18 date/impl#[ZipDateTime]month().()); |
| 40 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(day, built.dayrust-analyzer cargo async_zip 0.0.18 date/impl#[ZipDateTime]day().()); |
| 41 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(hour, built.hourrust-analyzer cargo async_zip 0.0.18 date/impl#[ZipDateTime]hour().()); |
| 42 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(minute, built.minuterust-analyzer cargo async_zip 0.0.18 date/impl#[ZipDateTime]minute().()); |
| 43 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(second, built.secondrust-analyzer cargo async_zip 0.0.18 date/impl#[ZipDateTime]second().()); |
| 44 | } |