Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

tai64: time is wrong in different ways

オープン
#2,012 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust
領域
backend

調査の方向性

tai64/src/lib.rs の UNIX_EPOCH、from_unix、to_unix から始め、次に提供された Rust リプロデューサーを実行します。crate の変換と、うるう秒を含む TAI、UTC、Unix 時刻の文書化された関係を比較します。定数と変換メソッドが意図された時間標準を一貫して表現できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Rust
スター
338
フォーク
188
平均マージ
4日 6時間
マージ済み PR(30日)
15

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RustCrypto/formats のほかの issue

RustCrypto/formats の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。