tai64: time is wrong in different ways
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia da tai64/src/lib.rs, esaminando UNIX_EPOCH, from_unix e to_unix, quindi esegui il riproduttore Rust fornito. Confronta le conversioni della crate con la relazione documentata tra TAI, UTC e il tempo Unix, inclusi i secondi intercalari. Il lavoro è completato quando le costanti e i metodi di conversione rappresentano coerentemente gli standard temporali previsti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
TLDR: Second assertion in the following code fails.
fn main() {
let now_tai = tai64::Tai64::now();
let now_std = std::time::SystemTime::now();
// making sure the second didn't change between measurements
assert_eq!(now_tai, tai64::Tai64::now());
let now_tai_unix: u64 = now_tai
.to_unix()
.try_into()
.expect("21st century");
let now_std_unix: u64 = now_std
.duration_since(std::time::SystemTime::UNIX_EPOCH)
.expect("21st century")
.as_secs();
assert_eq!(now_tai_unix, now_std_unix);
}
thread 'main' panicked at src/main.rs:17:5:
assertion `left == right` failed
left: 1756146344
right: 1756146317
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Time standards are anything but trivial. TAI, UTC, and Unix time are three different time standards. In particular, they differ in how they handle leap seconds. The crate tai64 attempts to solve the conversion between TAI64 and Unix timestamps, which are (semi)standardized binary representations of a moment in time in TAI and Unix time respectively. Since Unix time is defined from UTC, which in turn defined from TAI, we should discuss relationship between the latter two.
By definition, 1 January 1972 00:00:00 UTC is 1 January 1972 00:00:10 TAI exactly[^1]. Yet, at the moment of writing, The current difference between UTC and TAI is 37 seconds. (TAI is ahead of UTC by this amount)[^2]. Change in difference over time comes from leap seconds, which have been inserted in 27 times since 1972.
[^1]: Blair 1974, p. 32.
[^2]: Leap second and UT1-UTC information. NIST.
This means that the difference between representations of a moment in time in TAI and UTC is not only a function of the current moment in time but also of the moment in question.
The problem with the current implementation isn't limited to the offset being constant: it is inconsistent. In UNIX_EPOCH it is 37, but in the methods from_unix and to_unix, it is 10:
https://github.com/RustCrypto/formats/blob/950e25e5327f7ecc9fbd7fb585d1967cbd80067c/tai64/src/lib.rs#L40
https://github.com/RustCrypto/formats/blob/950e25e5327f7ecc9fbd7fb585d1967cbd80067c/tai64/src/lib.rs#L63
https://github.com/RustCrypto/formats/blob/950e25e5327f7ecc9fbd7fb585d1967cbd80067c/tai64/src/lib.rs#L68
- Lingua principale
- Rust
- Stelle
- 338
- Fork
- 188
- Merge medio
- 4g 6h
- PR unite (30g)
- 15
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di RustCrypto/formats
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
RustCrypto/formats#2389 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
RustCrypto/formats#2366 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
RustCrypto/formats#2430 · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
RustCrypto/formats#2428 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
RustCrypto/formats#2427 · 1 commento ·
Tutte le issue di RustCrypto/formats
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
bug core
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
JIT-compiled number -> Decimal conversion silently overflows instead of raising DECIMAL_OVERFLOW Apertafuzz
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ClickHouse/ClickHouse#122114 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
linebender/vello_svg#90 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100