}
}
+proc UTCFromISO {v} {
+ return [clock scan $v -format {%Y-%m-%d %H:%M:%S} -gmt 1]
+}
+
variable Leapsecs {
- 1483228800
- 1435708800
- 1341100800
- 1230768000
- 1136073600
- 915148800
- 867715200
- 820454400
- 773020800
- 741484800
- 709948800
- 662688000
- 631152000
- 567993600
- 489024000
- 425865600
- 394329600
- 362793600
- 315532800
- 283996800
- 252460800
- 220924800
- 189302400
- 157766400
- 126230400
- 94694400
- 78796800
+ "1972-07"
+ "1973-01"
+ "1974-01"
+ "1975-01"
+ "1976-01"
+ "1977-01"
+ "1978-01"
+ "1979-01"
+ "1980-01"
+ "1981-07"
+ "1982-07"
+ "1983-07"
+ "1985-07"
+ "1988-01"
+ "1990-01"
+ "1991-01"
+ "1992-07"
+ "1993-07"
+ "1994-07"
+ "1996-01"
+ "1997-07"
+ "1999-01"
+ "2006-01"
+ "2009-01"
+ "2012-07"
+ "2015-07"
+ "2017-01"
+}
+for {set i 0} {$i < [llength $Leapsecs]} {incr i} {
+ set v [lindex $Leapsecs $i]
+ set v [UTCFromISO "$v-01 00:00:00"]
+ set v [expr {$v + 10 + $i}]
+ lset Leapsecs $i $v
}
proc toTAI64 {v} {
variable Leapsecs
- set diff 10
- for {set i 0} {$i < [llength $Leapsecs]} {incr i} {
- if {$v > [lindex $Leapsecs $i]} {
- set diff [expr {$diff + [llength $Leapsecs] - $i}]
- break
- }
+ set i 0
+ for {} {$i < [llength $Leapsecs]} {incr i} {
+ if {$v < [lindex $Leapsecs $i]} { break }
}
- set v [expr {$v + 0x4000000000000000 + $diff}]
+ set v [expr {$v + 10 + $i}]
+ if {$v == [lindex $Leapsecs $i]} { incr v }
+ set v [expr {$v + 0x4000000000000000}]
toBE 8 $v
}
}
}
-proc UTCFromISO {v} {
- return [clock scan $v -format {%Y-%m-%d %H:%M:%S} -gmt 1]
-}
-
proc RAW {t v} {
char $t
add $v