]> Cypherpunks repositories - keks.git/commitdiff
Ability to skip TAI→UTC conversion
authorSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2025 08:10:22 +0000 (11:10 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 14 Jan 2025 08:10:22 +0000 (11:10 +0300)
go/ctx.go
go/unmarshal.go

index 7546f66143386b2ac265207c6fc3f1b90dc880eed698884d396340ce6f87d0b3..148a7b85a110173438e8fc2864c886a896caf452e987c7ea2e62120eaa0815f7 100644 (file)
--- a/go/ctx.go
+++ b/go/ctx.go
@@ -39,6 +39,9 @@ type DecodeOpts struct {
        // Leave TAI64* values as is, do not convert to time.Time during unmarshal.
        LeaveTAI64 bool
 
+       // Do not convert TAI to UTC.
+       LeaveTAI bool
+
        // Store items offsets.
        SaveOffsets bool
 }
index 88f10a23f3a2f12c9e06525e9d455f7c76d3a6c9f861033f266382e313d07ca5..08b4943ef7ff771cc51cc9553f2ce7bc03c75e8d49f14eca051f8f681d54a537 100644 (file)
@@ -94,18 +94,26 @@ func (ctx *Decoder) unmarshal(iter *Iterator) (v any, err error) {
                panic("float is unsupported")
        case types.TAI64:
                t := iter.TAI64()
-               if ctx.opts != nil && ctx.opts.LeaveTAI64 {
-                       return t, nil
-               } else {
-                       return toUTC(t.Time())
+               if ctx.opts != nil {
+                       if ctx.opts.LeaveTAI64 {
+                               return t, nil
+                       }
+                       if ctx.opts.LeaveTAI {
+                               return t.Time(), nil
+                       }
                }
+               return toUTC(t.Time())
        case types.TAI64N:
                t := iter.TAI64N()
-               if ctx.opts != nil && ctx.opts.LeaveTAI64 {
-                       return t, nil
-               } else {
-                       return toUTC(t.Time())
+               if ctx.opts != nil {
+                       if ctx.opts.LeaveTAI64 {
+                               return t, nil
+                       }
+                       if ctx.opts.LeaveTAI {
+                               return t.Time(), nil
+                       }
                }
+               return toUTC(t.Time())
        case types.TAI64NA:
                return iter.TAI64NA(), nil
        case types.Bin: