From 4481a77a1c4638d99237d1d1bd00a1ad2e0c6d15 Mon Sep 17 00:00:00 2001 From: "@0xb17bea125" Date: Sat, 3 Dec 2022 15:45:11 +0900 Subject: [PATCH] tzif: use scalar.Fn() to define a mapper ad hoc --- format/tzif/tzif.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/format/tzif/tzif.go b/format/tzif/tzif.go index 3e4fbd9f..91153325 100644 --- a/format/tzif/tzif.go +++ b/format/tzif/tzif.go @@ -82,10 +82,7 @@ func decodeTZifHeader(d *decode.D, name string) tzifHeader { return h } -type unixTimeToStrMapper struct { -} - -func (m unixTimeToStrMapper) MapScalar(s scalar.S) (scalar.S, error) { +var unixTimeToStr = scalar.Fn(func(s scalar.S) (scalar.S, error) { i, ok := s.Value().(int64) if !ok { return s, fmt.Errorf("expected int64 but got %T", s.Value()) @@ -93,9 +90,7 @@ func (m unixTimeToStrMapper) MapScalar(s scalar.S) (scalar.S, error) { s.Sym = time.Unix(i, 0).UTC().Format(time.RFC3339) return s, nil -} - -var unixTimeToStr unixTimeToStrMapper +}) func decodeTZifDataBlock(d *decode.D, h tzifHeader, decodeAsVer int, name string) { timeSize := 8 * 8