leapsecs.go | 16 ++++++++-------- diff --git a/leapsecs.go b/leapsecs.go index e4d915244e5259f6117417add0c58e0fc77c2ea6874a8d7967644d5187ba63cb..d78d594f0ffde22b39fd61240bca91c7103ba578c7178278e9a5c700a9e37fa2 100644 --- a/leapsecs.go +++ b/leapsecs.go @@ -27,9 +27,9 @@ // Database of Unix timestamps of the time when leap second occurred. // Library contains and initializes it with leap seconds up to 2016-12-31. var Leapsecs LeapsecsList -// Add leap seconds to the time (convert TAI to UTC). -func (leapsecs LeapsecsList) Add(tai time.Time) (utc time.Time) { - orig := tai.Unix() +// Add leap seconds to the time (convert UTC to TAI). +func (leapsecs LeapsecsList) Add(utc time.Time) (tai time.Time) { + orig := utc.Unix() v := orig v += Leapsecs1972 for _, leapsec := range Leapsecs { @@ -37,14 +37,14 @@ if v >= leapsec { v++ } } - utc = tai.Add(time.Second * time.Duration(v-orig)) + tai = utc.Add(time.Second * time.Duration(v-orig)) return } -// Subtract leap seconds from the time (convert UTC to TAI). -func (leapsecs LeapsecsList) Sub(utc time.Time) (tai time.Time, isLeap bool) { +// Subtract leap seconds from the time (convert TAI to UTC). +func (leapsecs LeapsecsList) Sub(tai time.Time) (utc time.Time, isLeap bool) { diff := int64(Leapsecs1972) - v := utc.Unix() + v := tai.Unix() for _, leapsec := range leapsecs { if v < leapsec { break @@ -55,7 +55,7 @@ isLeap = true break } } - tai = utc.Add(-time.Second * time.Duration(diff)) + utc = tai.Add(-time.Second * time.Duration(diff)) return }