Skip to content

Commit 0bd9dea

Browse files
authored
tai64: fix TAI offset and verify with GH Action (#1583)
1 parent f7288cf commit 0bd9dea

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Update Leap Seconds
2+
on:
3+
schedule:
4+
- cron: 0 0 * * 1
5+
6+
jobs:
7+
update:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
13+
- name: Update leap seconds in code
14+
run: |
15+
curl -o leap_seconds_list -L https://data.iana.org/time-zones/data/leap-seconds.list
16+
number=$(grep -v '^#' leap_seconds_list | tail -n1 | awk '{print $2}')
17+
sed -i "s/\(1970-01-01 00:00:\)[0-9]\+ TAI/\1${number} TAI/" tai64/src/lib.rs
18+
sed -i -E 's/(Self\()[0-9]+ \+ \(1 << 62\)\)/\1'"${number}"' + (1 << 62))/' tai64/src/lib.rs
19+
rm leap_seconds_list
20+
- name: Create Pull Request
21+
uses: peter-evans/create-pull-request@v7
22+
with:
23+
commit-message: update leap seconds in tai64
24+
title: Update leap seconds in tai64
25+
body: 'Following this source: https://data.iana.org/time-zones/data/leap-seconds.list, the leap seconds counter has been updated.'
26+
branch: update-leap-seconds
27+
base: master
28+
delete-branch: true

tai64/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const NANOS_PER_SECOND: u32 = 1_000_000_000;
3636
pub struct Tai64(pub u64);
3737

3838
impl Tai64 {
39-
/// Unix epoch in `TAI64`: 1970-01-01 00:00:10 TAI.
40-
pub const UNIX_EPOCH: Self = Self(10 + (1 << 62));
39+
/// Unix epoch in `TAI64`: 1970-01-01 00:00:37 TAI.
40+
pub const UNIX_EPOCH: Self = Self(37 + (1 << 62));
4141

4242
/// Length of serialized `TAI64` timestamp in bytes.
4343
pub const BYTE_SIZE: usize = 8;
@@ -151,7 +151,7 @@ impl Zeroize for Tai64N {
151151
}
152152

153153
impl Tai64N {
154-
/// Unix epoch in `TAI64N`: 1970-01-01 00:00:10 TAI.
154+
/// Unix epoch in `TAI64N`: 1970-01-01 00:00:37 TAI.
155155
pub const UNIX_EPOCH: Self = Self(Tai64::UNIX_EPOCH, 0);
156156

157157
/// Length of serialized `TAI64N` timestamp.

0 commit comments

Comments
 (0)