Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no millis? #539

Closed
hp8wvvvgnj6asjm7 opened this issue Dec 21, 2022 · 5 comments
Closed

no millis? #539

hp8wvvvgnj6asjm7 opened this issue Dec 21, 2022 · 5 comments
Labels
A-core Area: anything not otherwise covered C-question Category: seeking clarification on a topic

Comments

@hp8wvvvgnj6asjm7
Copy link

Am I missing something here?

println!("{:?}", OffsetDateTime::now_utc().unix_timestamp_nanos());
...? micros
...? millis
println!("{:?}", OffsetDateTime::now_utc().unix_timestamp());
@jhpratt
Copy link
Member

jhpratt commented Dec 21, 2022

Multiply it by 1000 or 1,000,000 and use unix_timestamp_nanos. The only reason there are even two methods is because they accept different types.

@jhpratt jhpratt closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2022
@jhpratt jhpratt added C-question Category: seeking clarification on a topic A-core Area: anything not otherwise covered labels Dec 21, 2022
@hp8wvvvgnj6asjm7
Copy link
Author

https://doc.rust-lang.org/nightly/core/time/struct.Duration.html#implementations

rust-lang/rust#57391

why would you not add this for the same ergonomic reasons?

@jhpratt
Copy link
Member

jhpratt commented Dec 21, 2022

I'm not sure I follow. A Duration and an OffsetDateTime are two completely different types with zero overlap in functionality.

@AshfordN
Copy link

On this note, I think it is important to explicitly state, in the docs, that the *_unix_timestamp() functions operate on seconds, as opposed to some other unit, such as milliseconds. I know it should be understood or expected that all Unix timestamps are in second, but this omission could potentially lead to confusion and ambiguity, since some external APIs, such as Javascript's Date API (in the context of a WASM module), returns millisecond timestamps.

@jhpratt
Copy link
Member

jhpratt commented Feb 15, 2023

@AshfordN The Unix timestamp is, by definition, in seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: anything not otherwise covered C-question Category: seeking clarification on a topic
Projects
None yet
Development

No branches or pull requests

3 participants