]> Cypherpunks repositories - gotai64n.git/commitdiff
Fixed mistakenly leading docstring master v4.1.1
authorSergey Matveev <stargrave@stargrave.org>
Mon, 7 Apr 2025 07:51:11 +0000 (10:51 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 7 Apr 2025 07:51:11 +0000 (10:51 +0300)
leapsecs.go

index dc768294353cd71de0f674fcc5a6a4ed303d293b..a480f0ee6feb8fe5273403776d515265823c04f2 100644 (file)
@@ -27,9 +27,9 @@ type LeapsecsList []int64
 // 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 @@ func (leapsecs LeapsecsList) Add(tai time.Time) (utc time.Time) {
                        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 @@ func (leapsecs LeapsecsList) Sub(utc time.Time) (tai time.Time, isLeap bool) {
                        break
                }
        }
-       tai = utc.Add(-time.Second * time.Duration(diff))
+       utc = tai.Add(-time.Second * time.Duration(diff))
        return
 }