3
3
4
4
//! ISO 8601 date and time with time zone.
5
5
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
-
17
6
#[ cfg( all( feature = "unstable-locales" , feature = "alloc" ) ) ]
18
7
use crate :: format:: Locale ;
19
8
use crate :: format:: {
@@ -30,6 +19,18 @@ use crate::offset::{FixedOffset, LocalResult, Offset, TimeZone, Utc};
30
19
use crate :: Date ;
31
20
use crate :: { expect, try_opt} ;
32
21
use 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 } ;
33
34
34
35
#[ cfg( any( feature = "rkyv" , feature = "rkyv-16" , feature = "rkyv-32" , feature = "rkyv-64" ) ) ]
35
36
use rkyv:: { Archive , Deserialize , Serialize } ;
@@ -1093,6 +1094,13 @@ impl DateTime<FixedOffset> {
1093
1094
}
1094
1095
}
1095
1096
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
+
1096
1104
impl < Tz : TimeZone > DateTime < Tz >
1097
1105
where
1098
1106
Tz :: Offset : fmt:: Display ,
0 commit comments