File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 55use crate :: query:: line_proto_term:: LineProtoTerm ;
66use crate :: query:: { QueryType , ValidQuery } ;
77use crate :: { Error , Query , Timestamp } ;
8+ use chrono:: { DateTime , TimeZone } ;
89use std:: fmt:: { Display , Formatter } ;
910
1011pub trait WriteType {
@@ -152,6 +153,20 @@ impl From<&str> for Type {
152153 Type :: Text ( b. into ( ) )
153154 }
154155}
156+
157+ impl < Tz : TimeZone > From < DateTime < Tz > > for Type {
158+ fn from ( dt : DateTime < Tz > ) -> Self {
159+ match dt. timestamp_nanos_opt ( ) {
160+ Some ( nanos) => Type :: SignedInteger ( nanos) ,
161+ None => {
162+ // For dates before 1677-09-21, or after
163+ // 2262-04-11, we're just going to return 0.
164+ Type :: SignedInteger ( 0 )
165+ }
166+ }
167+ }
168+ }
169+
155170impl < T > From < & T > for Type
156171where
157172 T : Copy + Into < Type > ,
You can’t perform that action at this time.
0 commit comments