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 5
5
use crate :: query:: line_proto_term:: LineProtoTerm ;
6
6
use crate :: query:: { QueryType , ValidQuery } ;
7
7
use crate :: { Error , Query , Timestamp } ;
8
+ use chrono:: { DateTime , TimeZone } ;
8
9
use std:: fmt:: { Display , Formatter } ;
9
10
10
11
pub trait WriteType {
@@ -152,6 +153,20 @@ impl From<&str> for Type {
152
153
Type :: Text ( b. into ( ) )
153
154
}
154
155
}
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
+
155
170
impl < T > From < & T > for Type
156
171
where
157
172
T : Copy + Into < Type > ,
You can’t perform that action at this time.
0 commit comments