@@ -12,7 +12,7 @@ use chrono::{
1212} ;
1313use chrono_tz:: Tz ;
1414use std:: {
15- fmt:: { self , Debug , Formatter } ,
15+ fmt:: { self , Debug , Display , Formatter } ,
1616 io,
1717} ;
1818
@@ -70,27 +70,26 @@ impl Debug for TimestampValue {
7070 }
7171}
7272
73- impl ToString for TimestampValue {
74- fn to_string ( & self ) -> String {
75- Utc . timestamp_nanos ( self . unix_nano )
76- . format_with_items (
77- [
78- Item :: Numeric ( Year , Zero ) ,
79- Item :: Literal ( "-" ) ,
80- Item :: Numeric ( Month , Zero ) ,
81- Item :: Literal ( "-" ) ,
82- Item :: Numeric ( Day , Zero ) ,
83- Item :: Literal ( "T" ) ,
84- Item :: Numeric ( Hour , Zero ) ,
85- Item :: Literal ( ":" ) ,
86- Item :: Numeric ( Minute , Zero ) ,
87- Item :: Literal ( ":" ) ,
88- Item :: Numeric ( Second , Zero ) ,
89- Item :: Fixed ( Fixed :: Nanosecond3 ) ,
90- ]
91- . iter ( ) ,
92- )
93- . to_string ( )
73+ impl Display for TimestampValue {
74+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
75+ let formatted = Utc . timestamp_nanos ( self . unix_nano ) . format_with_items (
76+ [
77+ Item :: Numeric ( Year , Zero ) ,
78+ Item :: Literal ( "-" ) ,
79+ Item :: Numeric ( Month , Zero ) ,
80+ Item :: Literal ( "-" ) ,
81+ Item :: Numeric ( Day , Zero ) ,
82+ Item :: Literal ( "T" ) ,
83+ Item :: Numeric ( Hour , Zero ) ,
84+ Item :: Literal ( ":" ) ,
85+ Item :: Numeric ( Minute , Zero ) ,
86+ Item :: Literal ( ":" ) ,
87+ Item :: Numeric ( Second , Zero ) ,
88+ Item :: Fixed ( Fixed :: Nanosecond3 ) ,
89+ ]
90+ . iter ( ) ,
91+ ) ;
92+ write ! ( f, "{}" , formatted)
9493 }
9594}
9695
0 commit comments