File tree 2 files changed +15
-0
lines changed 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -256,6 +256,7 @@ pub(crate) struct DateTime {
256
256
pub ( crate ) enum DateTimeBody {
257
257
Canonical ( Int64 ) ,
258
258
Relaxed ( String ) ,
259
+ Legacy ( i64 ) ,
259
260
}
260
261
261
262
impl DateTimeBody {
@@ -282,6 +283,7 @@ impl DateTime {
282
283
} ) ?;
283
284
Ok ( datetime)
284
285
}
286
+ DateTimeBody :: Legacy ( ms) => Ok ( crate :: DateTime :: from_millis ( ms) ) ,
285
287
}
286
288
}
287
289
}
Original file line number Diff line number Diff line change @@ -665,6 +665,19 @@ fn test_de_uuid_extjson_string() {
665
665
assert_eq ! ( actual_uuid_bson, expected_uuid_bson) ;
666
666
}
667
667
668
+ #[ test]
669
+ fn test_de_date_extjson_number ( ) {
670
+ let _guard = LOCK . run_concurrently ( ) ;
671
+
672
+ let ext_json_canonical = r#"{ "$date": { "$numberLong": "1136239445000" } }"# ;
673
+ let expected_date_bson: Bson = serde_json:: from_str ( ext_json_canonical) . unwrap ( ) ;
674
+
675
+ let ext_json_legacy_java = r#"{ "$date": 1136239445000 }"# ;
676
+ let actual_date_bson: Bson = serde_json:: from_str ( ext_json_legacy_java) . unwrap ( ) ;
677
+
678
+ assert_eq ! ( actual_date_bson, expected_date_bson) ;
679
+ }
680
+
668
681
#[ test]
669
682
fn test_de_oid_string ( ) {
670
683
let _guard = LOCK . run_concurrently ( ) ;
You can’t perform that action at this time.
0 commit comments