@@ -126,7 +126,7 @@ impl Cast<String> for Value {
126
126
Value :: I64 ( value) => lexical:: to_string ( value) ,
127
127
Value :: F64 ( value) => lexical:: to_string ( value) ,
128
128
Value :: Str ( value) => value,
129
- Value :: Timestamp ( value) => lexical :: to_string ( value) ,
129
+ Value :: Timestamp ( value) => NaiveDateTime :: from_timestamp ( value, 0 ) . to_string ( ) ,
130
130
Value :: Null => String :: from ( "NULL" ) ,
131
131
_ => return Err ( unimplemented_cast ( & self , ValueType :: Str ) ) ,
132
132
} )
@@ -241,8 +241,8 @@ impl CastWithRules<NaiveDateTime> for Value {
241
241
. ok_or_else ( || ValueError :: ParseError ( try_value. clone ( ) , "TIMESTAMP" ) . into ( ) )
242
242
}
243
243
const TRY_RULES_TIMESTAMP : [ i64 ; 1 ] = [ 000 ] ;
244
- const TRY_RULES_DATETIME : [ i64 ; 7 ] = [ 010 , 011 , 020 , 021 , 030 , 031 , 060 ] ;
245
- const TRY_RULES_DATE : [ i64 ; 4 ] = [ 022 , 033 , 032 , 061 ] ; // 033 should go before 032
244
+ const TRY_RULES_DATETIME : [ i64 ; 9 ] = [ 010 , 011 , 020 , 021 , 030 , 031 , 060 , 062 , 063 ] ;
245
+ const TRY_RULES_DATE : [ i64 ; 6 ] = [ 022 , 033 , 032 , 061 , 064 , 040 ] ; // 033 should go before 032
246
246
const TRY_RULES_TIME : [ i64 ; 2 ] = [ 100 , 101 ] ;
247
247
248
248
match rule {
@@ -264,17 +264,6 @@ impl CastWithRules<NaiveDateTime> for Value {
264
264
// From Timestamp (Default)
265
265
self . cast ( )
266
266
}
267
- // 01* - Statically specifically defined by accepted standards bodies
268
- /*Value::I64(010) => {
269
- // From RFC 3339 format
270
- let datetime_string: String = self.cast()?;
271
- DateTime::parse_from_rfc3339(datetime_string.as_str()).map_err(parse_error_into)
272
- }
273
- Value::I64(011) => {
274
- // From RFC 2822 format
275
- let datetime_string: String = self.cast()?;
276
- DateTime::parse_from_rfc2822(datetime_string.as_str()).map_err(parse_error_into)
277
- }*/
278
267
// 02* - Conventional
279
268
// - From Database format (YYYY-MM-DD HH:MM:SS)
280
269
Value :: I64 ( 020 ) => for_format_datetime ( self , "%F %T" ) ,
@@ -293,11 +282,15 @@ impl CastWithRules<NaiveDateTime> for Value {
293
282
// - From dd-Mon-YY
294
283
Value :: I64 ( 033 ) => for_format_date ( self , "%e-%b-%y" ) ,
295
284
285
+ Value :: I64 ( 040 ) => for_format_date ( self , "%Y%m%d" ) ,
286
+
296
287
// 0(5-8)* - Locales
297
288
// 06* - Australia
298
289
Value :: I64 ( 060 ) => for_format_datetime ( self , "%d/%m/%Y %H:%M" ) ,
299
290
Value :: I64 ( 061 ) => for_format_date ( self , "%d/%m/%Y" ) ,
300
- // (TODO(?))
291
+ Value :: I64 ( 062 ) => for_format_datetime ( self , "%d/%m/%Y %H:%M:%S" ) ,
292
+ Value :: I64 ( 063 ) => for_format_datetime ( self , "%d%m%Y %H:%M:%S" ) ,
293
+ Value :: I64 ( 064 ) => for_format_date ( self , "%d%m%Y" ) ,
301
294
302
295
// 10* - Time
303
296
// - (HH:MM:SS)
0 commit comments