File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 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 {
256256pub ( crate ) enum DateTimeBody {
257257 Canonical ( Int64 ) ,
258258 Relaxed ( String ) ,
259+ Legacy ( i64 ) ,
259260}
260261
261262impl DateTimeBody {
@@ -282,6 +283,7 @@ impl DateTime {
282283 } ) ?;
283284 Ok ( datetime)
284285 }
286+ DateTimeBody :: Legacy ( ms) => Ok ( crate :: DateTime :: from_millis ( ms) ) ,
285287 }
286288 }
287289}
Original file line number Diff line number Diff line change @@ -665,6 +665,19 @@ fn test_de_uuid_extjson_string() {
665665 assert_eq ! ( actual_uuid_bson, expected_uuid_bson) ;
666666}
667667
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+
668681#[ test]
669682fn test_de_oid_string ( ) {
670683 let _guard = LOCK . run_concurrently ( ) ;
You can’t perform that action at this time.
0 commit comments