bson-rust
bson-rust copied to clipboard
DateTime::from_from_millis should return Result<DateTime, _>.
Versions/Environment
- What version of Rust are you using? 1.62.0
- What operating system are you using? Linux
- What versions of the driver and its dependencies are you using? (Run
cargo pkgid mongodb
&cargo pkgid bson
) mongodb: 2.3.0 - bson: 2.3.0
Describe the bug
DateTime::from_millis
always return a DateTime
even if the timestamp is bigger than 31494784780799999
.
BE SPECIFIC:
- Do you have any particular output that demonstrates this problem?
- If you know how to reproduce this bug, please include a code snippet here:
let valid_date = DateTime::from_millis(31494784780799999);
println!("{valid_date"}); // +999999-12-31 23:59:59.999 +00:00:00
let invalid_date_but_valid_i64 = DateTime::from_millis(31494784780800000);
println!("{invalid_date_but_valid_i64"}); // 31494784780800000
It can be fine if DateTime::from_millis
return Result<DateTime, _>
instead.
Hi @MathieuRA, thanks for reaching out.
Why do you say that 31494784780799999
should be the max valid timestamp value - just because the debug output you show isn't formatted as a date? The output varies there because we delegate to the time
crate for the Debug
implementation, but for dates outside of time's max supported range, we just output the i64
value.
the BSON format itself allows dates all the way from i64::MIN
to i64::MAX
.
There has not been any recent activity on this ticket, so we are marking it as stale. If we do not hear anything further from you, this issue will be automatically closed in one week.
There has not been any recent activity on this ticket, so we are closing it. Thanks for reaching out and please feel free to file a new issue if you have further questions.