Zoned::now() with nanoseconds #110
-
I've been trying to get a I've tried these two things. let now = Zoned::now();
let nanos = now.timestamp().as_nanosecond();
eprintln!("nanos: {:?}", nanos); and let now = Zoned::now().round(Unit::Nanosecond).map_err(|err| {
LabeledError::new(format!(
"Error getting current time with Zoned::now(). Error: {}",
err.to_string()
))
})?;
let nanos = now.timestamp().as_nanosecond();
eprintln!("nanos: {:?}", nanos); Example of my output ❯ dt now
nanos: 1724106013597000000
Mon, 19 Aug 2024 17:20:13 -0500 (now)
❯ dt now
nanos: 1724106015838647000
Mon, 19 Aug 2024 17:20:15 -0500 (now)
❯ dt now
nanos: 1724106017747553000
Mon, 19 Aug 2024 17:20:17 -0500 (now)
❯ dt now
nanos: 1724106019417424000
Mon, 19 Aug 2024 17:20:19 -0500 (now) |
Beta Was this translation helpful? Give feedback.
Answered by
BurntSushi
Aug 19, 2024
Replies: 1 comment 1 reply
-
The most likely explanation is that your platform doesn't have nanosecond resolution. It looks like it only has microsecond resolution. So getting nanoseconds is probably fundamentally impossible as it is a limitation of your hardware. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
BurntSushi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The most likely explanation is that your platform doesn't have nanosecond resolution. It looks like it only has microsecond resolution. So getting nanoseconds is probably fundamentally impossible as it is a limitation of your hardware.