bson-rust icon indicating copy to clipboard operation
bson-rust copied to clipboard

DateTime::from_from_millis should return Result<DateTime, _>.

Open MathieuRA opened this issue 2 years ago • 1 comments

Versions/Environment

  1. What version of Rust are you using? 1.62.0
  2. What operating system are you using? Linux
  3. 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.

MathieuRA avatar Aug 14 '22 16:08 MathieuRA

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.

kmahar avatar Aug 15 '22 18:08 kmahar

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.

github-actions[bot] avatar Aug 23 '22 02:08 github-actions[bot]

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.

github-actions[bot] avatar Aug 31 '22 02:08 github-actions[bot]