-
Notifications
You must be signed in to change notification settings - Fork 14k
Clarify SystemTime doesn't know about leap seconds #53579
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
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @sfackler or @steveklabnik perhaps |
|
SystemTime doesn't expose any concept of years - how is the behavior with respect to leap seconds visible to a user? |
|
@sfackler when there are no leap seconds in
|
|
I think the concept of "leap second" is related rather to the underlying clock from which |
|
@WiSaGaN I’m not sure what resync you are talking about, but winapi FILETIME ignores leap second adjustments. There’s a good demo of that fact on stackoverflow. |
|
@stepancheg Say we had a leap second at the end of 2016-12-31. If we got
|
AFAIU after looking at how
Yes, |
Are you sure this can happen even when there is no clock syncing between the host and an external clock source? |
|
Windows does not know about leap seconds. The clock simply ends up falling out of sync with the actual time until the next time Windows syncs to an external time server at which point the time resyncs jumping backwards in time. So when Windows syncs after a leap second occurs (assuming that the time is perfectly synced otherwise) there will be a minute where monotonic clocks report that 61 seconds have passed while |
|
@pietroalbini why it is now "waiting on author"? The last question by @WiSaGaN was answered by @retep998. |
Time is formatted as ISO-8601 in UTC timezone.
Nanoseconds are printed by default, unless precision is specified:
```
1966-10-31T14:13:20.123456789Z // by default: {}
1966-10-31T14:13:20Z // with format {.0}
1966-10-31T14:13:20.1Z // with format {.1}
```
Implementation is partially copied from `chrono` crate (CC
@quodlibetor).
This is not fully-featured date-time implementation. The motivation
for this commit is to be able to quickly understand what system
time is (e. g. when printed in logs) without introducing external
dependencies.
Format is similar to `java.time.Instant.toString()` output except
that Java truncates trailing zeros by default:
https://repl.it/repls/NauticalSeveralWheel
I think it's better to not truncate zeros by default, because:
* data output (e. g. in logs) look better when field length is the same,
e. g. with default Java formatter this is how log output may look like:
```
1966-10-31T14:13:20.123456789Z Server started
1966-10-31T14:13:21Z Connection accepted
1966-10-31T14:13:21.567Z Request started
```
* precision information is lost (e. g. when reading string
1966-10-31T14:13:20Z it's not clear, is it exactly zero millis, or
timestamp has seconds precision)
This patch depends on leap seconds clarification:
rust-lang#53579
|
Ping from triage @sfackler: I believe this PR requires your review. |
|
The sentence being added seems to introduce more questions than it answers for me at least. It should probably include some concrete examples of how and when the leap second treatment is relevant to a user. |
|
Triage; @stepancheg This PR requires your attention. |
|
Ping from triage @stepancheg: I'm closing this due to inactivity per the triage procedure. Thank you for your contribution and please feel free to (re-)open this or another PR in the future. |
No description provided.