mongodb / bson-rust

Encoding and decoding support for BSON in Rust
MIT License
405 stars 134 forks source link

Time's "large-dates" feature should be optional #475

Open dennisorlando opened 6 months ago

dennisorlando commented 6 months ago

Hi, when parsing a time::PrimitiveDateTime, the program's execution changes when the "large-dates" feature is enabled, due to some ambiguities when parsing a datetime. bson has such feature enabled by default, thus potentially modifying how a program works. In our case, we got some panics which we didn't know where they came from.

Would it be possible to remove the "large-dates" feature from time and perhaps make it optional?

abr-egn commented 6 months ago

We enable the large-dates feature because part of the bson test corpus includes dates in the Y10k+ range; I do think you make a good case for making that optional when it's guaranteed that inputs won't have years that large.

Unfortunately, removing the feature at this point would be a breaking change, so I've filed https://jira.mongodb.org/browse/RUST-1960 for it to be included in version 3.0 of the bson crate.

dennisorlando commented 2 months ago

Updates: this is also getting addressed at https://github.com/time-rs/time/pull/709, which might provide you a solution which is not breaking