Skip to content

Commit

Permalink
add script with some source options, as maia.usno.navy.mil is still down
Browse files Browse the repository at this point in the history
  • Loading branch information
dropwhile committed Sep 22, 2021
1 parent 2ef1698 commit d90842d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Build
strategy:
matrix:
goVer: ["1.11.x", "1.12.x", "1.13.x"]
goVer: ["1.13.x", "1.17.x"]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/leaps.dat
6 changes: 3 additions & 3 deletions tools/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ func main() {
}

line = strings.TrimSpace(line)
if line == "" {
if line == "" || strings.HasPrefix(line, ";") {
continue
}

parts := strings.Fields(line)
t, err := time.Parse("2006 Jan 2", strings.Title(strings.Join(parts[0:3], " ")))
t, err := time.Parse("2006-1-2", strings.Title(strings.Join(parts[0:3], "-")))
if err != nil {
fmt.Println(err)
continue
Expand All @@ -121,7 +121,7 @@ func main() {
continue
}

s, err := strconv.ParseFloat(parts[6], 32)
s, err := strconv.ParseFloat(parts[3], 32)
if err != nil {
fmt.Println(err)
continue
Expand Down
12 changes: 12 additions & 0 deletions tools/update-leaps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# sometimes sites go offline, so list a few options.
# just use one.
{
#curl -s 'http://maia.usno.navy.mil/ser7/tai-utc.dat'
#curl -s 'https://cdf.gsfc.nasa.gov/html/CDFLeapSeconds.txt'
#curl -s 'https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat'| grep -v '^#'| awk '{print $4" "$3" "$2" "$5}'
} > leaps.dat

go run ./tools/generate.go -input leaps.dat -output offsets.go -pkg tai64
go fmt offsets.go

0 comments on commit d90842d

Please sign in to comment.