33
44//! ISO 8601 date and time with time zone.
55
6- #[ cfg( all( feature = "alloc" , not( feature = "std" ) , not( test) ) ) ]
7- use alloc:: string:: String ;
8- use core:: borrow:: Borrow ;
9- use core:: cmp:: Ordering ;
10- use core:: fmt:: Write ;
11- use core:: ops:: { Add , AddAssign , Sub , SubAssign } ;
12- use core:: time:: Duration ;
13- use core:: { fmt, hash, str} ;
14- #[ cfg( feature = "std" ) ]
15- use std:: time:: { SystemTime , UNIX_EPOCH } ;
16-
176#[ cfg( all( feature = "unstable-locales" , feature = "alloc" ) ) ]
187use crate :: format:: Locale ;
198use crate :: format:: {
@@ -30,6 +19,18 @@ use crate::offset::{FixedOffset, LocalResult, Offset, TimeZone, Utc};
3019use crate :: Date ;
3120use crate :: { expect, try_opt} ;
3221use crate :: { Datelike , Months , TimeDelta , Timelike , Weekday } ;
22+ #[ cfg( all( feature = "alloc" , not( feature = "std" ) , not( test) ) ) ]
23+ use alloc:: string:: String ;
24+ use core:: borrow:: Borrow ;
25+ use core:: cmp:: Ordering ;
26+ use core:: fmt:: Write ;
27+ use core:: ops:: { Add , AddAssign , Sub , SubAssign } ;
28+ use core:: time:: Duration ;
29+ use core:: { fmt, hash, str} ;
30+ #[ cfg( feature = "defmt" ) ]
31+ use defmt:: { Format , Formatter } ;
32+ #[ cfg( feature = "std" ) ]
33+ use std:: time:: { SystemTime , UNIX_EPOCH } ;
3334
3435#[ cfg( any( feature = "rkyv" , feature = "rkyv-16" , feature = "rkyv-32" , feature = "rkyv-64" ) ) ]
3536use rkyv:: { Archive , Deserialize , Serialize } ;
@@ -1093,6 +1094,13 @@ impl DateTime<FixedOffset> {
10931094 }
10941095}
10951096
1097+ #[ cfg( feature = "defmt" ) ]
1098+ impl < Tz : TimeZone > Format for DateTime < Tz > {
1099+ fn format ( & self , fmt : Formatter ) {
1100+ defmt:: write!( fmt, "{=i32:04}-{=u32:02}-{=u32:02}" , self . year( ) , self . month( ) , self . day( ) ) ;
1101+ }
1102+ }
1103+
10961104impl < Tz : TimeZone > DateTime < Tz >
10971105where
10981106 Tz :: Offset : fmt:: Display ,
0 commit comments