@@ -28,7 +28,7 @@ namespace nmos
2828 // tai_clock::time_point (or tai_clock::duration, since NMOS uses relative timestamps in a few places)
2929 };
3030
31- // tai_clock is a std ::chrono Clock for generating and manipulating tai timestamps
31+ // tai_clock is a bst ::chrono Clock for generating and manipulating tai timestamps
3232 struct tai_clock
3333 {
3434 // "It is suggested (although not mandated) that these timestamps are stored with nanosecond resolution."
@@ -46,6 +46,9 @@ namespace nmos
4646 // time points; nmos::strictly_increasing_update is used to prevent duplicate values in nmos::resources
4747 static const bool is_steady = bst::chrono::system_clock::is_steady;
4848
49+ // UTC is 37 seconds behind TAI; see comments below for details
50+ static const duration tai_offset () { return bst::chrono::seconds (37 ); }
51+
4952 static time_point now ()
5053 {
5154 // "NMOS specifications shall use the PTP/SMPTE Epoch, i.e. 1 January 1970 00:00:00 TAI."
@@ -69,11 +72,9 @@ namespace nmos
6972 // and https://en.wikipedia.org/wiki/International_Atomic_Time
7073 // and https://github.com/HowardHinnant/date/issues/129
7174 // and https://cr.yp.to/proto/utctai.html
72- // and https://www.iers.org/SharedDocs/News/EN/BulletinC.html
73- // and https://www.ietf.org/timezones/data/leap-seconds.list
74- static const duration tai_offset = bst::chrono::seconds (37 );
75-
76- return time_point (tai_offset + bst::chrono::system_clock::now ().time_since_epoch ());
75+ // and https://datacenter.iers.org/data/latestVersion/bulletinC.txt
76+ // and https://data.iana.org/time-zones/data/leap-seconds.list
77+ return time_point (tai_offset () + bst::chrono::system_clock::now ().time_since_epoch ());
7778 }
7879 };
7980
0 commit comments