/*
-go.cypherpunks.ru/tai64n -- Pure Go TAI64N implementation
+go.cypherpunks.ru/tai64n -- Pure Go TAI64/TAI64N implementation
Copyright (C) 2020-2021 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
import (
"bufio"
+ "flag"
+ "fmt"
+ "io/ioutil"
"log"
"os"
"strings"
"time"
- "go.cypherpunks.ru/tai64n"
+ "go.cypherpunks.ru/tai64n/v2"
)
func main() {
log.SetFlags(0)
+ flag.Usage = func() {
+ fmt.Fprintf(
+ flag.CommandLine.Output(),
+ "Replace \"@HEX(TAI64)\"-prefixed line with human readable UTC.\n",
+ )
+ flag.PrintDefaults()
+ }
+ leapsecs := flag.Bool("leapsecs", false, "Take leap seconds into account: honest TAI->UTC")
+ db := flag.String("leapsecsdb", "", "Use that leapsecs.dat leap seconds database")
+ flag.Parse()
+
+ if *db != "" {
+ buf, err := ioutil.ReadFile(*db)
+ if err != nil {
+ log.Fatalln(err)
+ }
+ tai64n.LeapsecsDBLoad(buf)
+ }
+
scanner := bufio.NewScanner(os.Stdin)
var err error
var s string
if err != nil {
log.Fatalln(err)
}
+ if *leapsecs {
+ t = tai64n.LeapsecsSub(t)
+ }
os.Stdout.WriteString(t.Format(tai64n.LocalFmt) + s[sep:] + "\n")
}
}