From 87f96608cc3cf8dd25c84fe528115d8e7858a7c0dc38c00b284a52e725662795 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 15 Apr 2025 11:13:59 +0300 Subject: [PATCH] Omit empty ns/as --- go/cmd/pp/tcl.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/go/cmd/pp/tcl.go b/go/cmd/pp/tcl.go index aeb0daa..fc08e32 100644 --- a/go/cmd/pp/tcl.go +++ b/go/cmd/pp/tcl.go @@ -29,7 +29,7 @@ import ( "go.cypherpunks.su/tai64n/v4" ) -func tclTAI(t time.Time, ns int, as uint64) { +func tclTAI(t time.Time, ns, as int) { utc, isLeap := tai64n.Leapsecs.Sub(t) year := utc.Year() if year < 0 { @@ -38,8 +38,14 @@ func tclTAI(t time.Time, ns int, as uint64) { if isLeap || year > 9999 { fmt.Printf("TAI64 %d %d %d", t.Unix(), ns, as) } else { - fmt.Printf("TAI64 [ToTAI [ISOToSec \"%s\"]] %d %d", - utc.Format("2006-01-02 15:04:05"), ns, as) + s := `TAI64 [ToTAI [ISOToSec "` + utc.Format("2006-01-02 15:04:05") + `"]]` + if ns > 0 { + s += " " + strconv.Itoa(ns) + } + if as > 0 { + s += " " + strconv.Itoa(as) + } + fmt.Print(s) } } @@ -116,7 +122,7 @@ func tcl(iter *keks.Iterator, count int, inList, inMap bool) { var n tai64n.TAI64N copy(n[:], tai[:]) t := n.Time() - tclTAI(t, t.Nanosecond(), be.Get(tai[12:])) + tclTAI(t, t.Nanosecond(), int(be.Get(tai[12:]))) case types.Magic: allPrintable := true magic := iter.Magic() -- 2.48.1