1use icu_calendar::Gregorian;
6
7use crate::zone::UtcOffset;
8use crate::ZonedDateTime;
9use crate::{DateTime, Hour, Minute, Nanosecond, Second, Time};
10
11impl From<time::Time> for Time {
12 fn from(time: time::Time) -> Self {
13 Time {
14 hour: Hour(time.hour()),
15 minute: Minute(time.minute()),
16 second: Second(time.second()),
17 subsecond: Nanosecond(time.nanosecond()),
18 }
19 }
20}
21
22impl From<time::PrimitiveDateTime> for DateTime<Gregorian> {
23 fn from(chrono: time::PrimitiveDateTime) -> Self {
24 Self {
25 date: chrono.date().into(),
26 time: chrono.time().into(),
27 }
28 }
29}
30
31impl From<time::UtcOffset> for UtcOffset {
32 fn from(other: time::UtcOffset) -> Self {
33 UtcOffset::from_seconds_unchecked(other.whole_seconds())
34 }
35}
36
37impl From<&time::OffsetDateTime> for ZonedDateTime<Gregorian, UtcOffset> {
38 fn from(other: &time::OffsetDateTime) -> Self {
39 let date = other.date().into();
40 let time = other.time().into();
41 let zone = other.offset().into();
42
43 ZonedDateTime { date, time, zone }
44 }
45}