1
1
mirror of https://github.com/wader/fq.git synced 2024-12-23 05:13:30 +03:00

tzif: use scalar.Fn() to define a mapper ad hoc

This commit is contained in:
@0xb17bea125 2022-12-03 15:45:11 +09:00
parent abde823a79
commit 4481a77a1c

View File

@ -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