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:
parent
abde823a79
commit
4481a77a1c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user