I run the following code:
fn main() {
let utc0 = Epoch::from_gregorian_utc_hms(2016, 12, 31, 23, 59, 0);
let t0 = utc0.to_tai_seconds();
println!("T0={}, TAI0={}", utc0.to_gregorian_str(hifitime::TimeScale::UTC), t0);
let mut t1 = t0;
for dt in 1..62 {
t1 = t1 + 1.;
let utc1 = Epoch::from_tai_seconds(t1);
let utc2 = Epoch::from_utc_seconds(utc0.to_utc_seconds() + (dt as f64));
println!("+{} sec, TAI={}, T1={}, T2={}", dt, t1,
utc1.to_gregorian_str(hifitime::TimeScale::UTC),
utc2.to_gregorian_str(hifitime::TimeScale::UTC));
}
}
And the output is
T0=2016-12-31T23:59:00 UTC, TAI0=3692217576
+1 sec, TAI=3692217577, T1=2016-12-31T23:59:01 UTC, T2=2016-12-31T23:59:01 UTC
...
+22 sec, TAI=3692217598, T1=2016-12-31T23:59:22 UTC, T2=2016-12-31T23:59:22 UTC
+23 sec, TAI=3692217599, T1=2016-12-31T23:59:23 UTC, T2=2016-12-31T23:59:23 UTC
+24 sec, TAI=3692217600, T1=2016-12-31T23:59:23 UTC, T2=2016-12-31T23:59:24 UTC <-- leap second for T1
+25 sec, TAI=3692217601, T1=2016-12-31T23:59:24 UTC, T2=2016-12-31T23:59:25 UTC
...
+59 sec, TAI=3692217635, T1=2016-12-31T23:59:58 UTC, T2=2016-12-31T23:59:59 UTC
+60 sec, TAI=3692217636, T1=2016-12-31T23:59:59 UTC, T2=2017-01-01T00:00:00 UTC
+61 sec, TAI=3692217637, T1=2017-01-01T00:00:00 UTC, T2=2017-01-01T00:00:01 UTC
When I initiate Epoch using from_tai_seconds, leap second appears at 2016-12-31T23:59:23 UTC or 2017-01-01T00:00:00 TAI. But if I use from_utc_seconds, there is no leap second.
I use hifitime = "4.1.3".
I run the following code:
And the output is
When I initiate Epoch using
from_tai_seconds, leap second appears at2016-12-31T23:59:23 UTCor2017-01-01T00:00:00 TAI. But if I usefrom_utc_seconds, there is no leap second.I use
hifitime = "4.1.3".