From a78895294e694a129ead62bf52ccf277e83382d1 Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Wed, 23 Oct 2024 01:22:12 +0200 Subject: [PATCH 1/2] Add new action to update leap seconds automatically and the first value update. --- .../workflows/tai64_update_leap_seconds.yml | 27 +++++++++++++++++++ tai64/src/lib.rs | 6 ++--- 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/tai64_update_leap_seconds.yml diff --git a/.github/workflows/tai64_update_leap_seconds.yml b/.github/workflows/tai64_update_leap_seconds.yml new file mode 100644 index 000000000..103e9bd4f --- /dev/null +++ b/.github/workflows/tai64_update_leap_seconds.yml @@ -0,0 +1,27 @@ +name: Update Leap Seconds +on: + schedule: + - cron: 0 0 * * 1 + +jobs: + update: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Update leap seconds in code + run: | + curl -o leap_seconds_list -L https://data.iana.org/time-zones/data/leap-seconds.list + number=$(grep -v '^#' leap_seconds_list | tail -n1 | awk '{print $2}') + sed -i "s/\(1970-01-01 00:00:\)[0-9]\+ TAI/\1${number} TAI/" tai64/src/lib.rs + sed -i -E 's/(Self\()[0-9]+ \+ \(1 << 62\)\)/\1'"${number}"' + (1 << 62))/' tai64/src/lib.rs + rm leap_seconds_list + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + commit-message: update leap seconds in tai64 + title: Update leap seconds in tai64 + body: 'Following this source: https://data.iana.org/time-zones/data/leap-seconds.list, the leap seconds counter has been updated.' + branch: update-leap-seconds + base: master diff --git a/tai64/src/lib.rs b/tai64/src/lib.rs index d7f92d584..2ffcfc618 100644 --- a/tai64/src/lib.rs +++ b/tai64/src/lib.rs @@ -36,8 +36,8 @@ const NANOS_PER_SECOND: u32 = 1_000_000_000; pub struct Tai64(pub u64); impl Tai64 { - /// Unix epoch in `TAI64`: 1970-01-01 00:00:10 TAI. - pub const UNIX_EPOCH: Self = Self(10 + (1 << 62)); + /// Unix epoch in `TAI64`: 1970-01-01 00:00:37 TAI. + pub const UNIX_EPOCH: Self = Self(37 + (1 << 62)); /// Length of serialized `TAI64` timestamp in bytes. pub const BYTE_SIZE: usize = 8; @@ -151,7 +151,7 @@ impl Zeroize for Tai64N { } impl Tai64N { - /// Unix epoch in `TAI64N`: 1970-01-01 00:00:10 TAI. + /// Unix epoch in `TAI64N`: 1970-01-01 00:00:37 TAI. pub const UNIX_EPOCH: Self = Self(Tai64::UNIX_EPOCH, 0); /// Length of serialized `TAI64N` timestamp. From 19e70e1dd7c3fe68f195c5a23e82ddc3445c64f3 Mon Sep 17 00:00:00 2001 From: AurelienFT Date: Wed, 23 Oct 2024 01:39:15 +0200 Subject: [PATCH 2/2] Add deletion of tai64 leap seconds update branch --- .github/workflows/tai64_update_leap_seconds.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tai64_update_leap_seconds.yml b/.github/workflows/tai64_update_leap_seconds.yml index 103e9bd4f..df0be3a87 100644 --- a/.github/workflows/tai64_update_leap_seconds.yml +++ b/.github/workflows/tai64_update_leap_seconds.yml @@ -25,3 +25,4 @@ jobs: body: 'Following this source: https://data.iana.org/time-zones/data/leap-seconds.list, the leap seconds counter has been updated.' branch: update-leap-seconds base: master + delete-branch: true