diff --git a/msgp/json_bytes.go b/msgp/json_bytes.go index 88ec6045..d4fbda63 100644 --- a/msgp/json_bytes.go +++ b/msgp/json_bytes.go @@ -72,7 +72,7 @@ func writeNext(w jsWriter, msg []byte, scratch []byte, depth int) ([]byte, []byt if err != nil { return nil, scratch, err } - if et == TimeExtension { + if et == TimeExtension || et == MsgTimeExtension { t = TimeType } } @@ -276,7 +276,7 @@ func rwExtensionBytes(w jsWriter, msg []byte, scratch []byte, depth int) ([]byte } // if it's time.Time - if et == TimeExtension { + if et == TimeExtension || et == MsgTimeExtension { var tm time.Time tm, msg, err = ReadTimeBytes(msg) if err != nil { diff --git a/msgp/read.go b/msgp/read.go index 1adca170..d15355e2 100644 --- a/msgp/read.go +++ b/msgp/read.go @@ -260,7 +260,7 @@ func (m *Reader) NextType() (Type, error) { return Complex64Type, nil case Complex128Extension: return Complex128Type, nil - case TimeExtension: + case TimeExtension, MsgTimeExtension: return TimeType, nil } } @@ -1287,7 +1287,7 @@ func (m *Reader) ReadTime() (t time.Time, err error) { t = time.Unix(sec, int64(nsec)).Local() _, err = m.R.Skip(15) return - case -1: + case MsgTimeExtension: switch length { case 4, 8, 12: var tmp [12]byte diff --git a/msgp/read_bytes.go b/msgp/read_bytes.go index 17d63bc8..292704dd 100644 --- a/msgp/read_bytes.go +++ b/msgp/read_bytes.go @@ -29,7 +29,7 @@ func NextType(b []byte) Type { tp = int8(b[spec.size-1]) } switch tp { - case TimeExtension: + case TimeExtension, MsgTimeExtension: return TimeType case Complex128Extension: return Complex128Type @@ -1094,7 +1094,7 @@ func ReadTimeBytes(b []byte) (t time.Time, o []byte, err error) { sec, nsec := getUnix(b) t = time.Unix(sec, int64(nsec)).Local() return - case -1: + case MsgTimeExtension: switch len(b) { case 4: t = time.Unix(int64(binary.BigEndian.Uint32(b)), 0).Local()