MCPcopy
hub / github.com/tinylib/msgp / WriteTime

Method WriteTime

msgp/write.go:638–649  ·  view source on GitHub ↗

WriteTime writes a time.Time object to the wire. Time is encoded as Unix time, which means that location (time zone) data is removed from the object. The encoded object itself is 12 bytes: 8 bytes for a big-endian 64-bit integer denoting seconds elapsed since "zero" Unix time, followed by 4 bytes f

(t time.Time)

Source from the content-addressed store, hash-verified

636// heavily on the internal representation used by the
637// time package.)
638func (mw *Writer) WriteTime(t time.Time) error {
639 t = t.UTC()
640 o, err := mw.require(15)
641 if err != nil {
642 return err
643 }
644 mw.buf[o] = mext8
645 mw.buf[o+1] = 12
646 mw.buf[o+2] = TimeExtension
647 putUnix(mw.buf[o+3:], t.Unix(), int32(t.Nanosecond()))
648 return nil
649}
650
651// WriteTimeExt will write t using the official msgpack extension spec.
652// https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type

Callers 12

TestReadTimeBytesFunction · 0.95
BenchmarkSkipBytesFunction · 0.95
TestTimeFunction · 0.95
BenchmarkSkipFunction · 0.95
TestCopyNextFunction · 0.95
TestWriteTimeFunction · 0.95
BenchmarkWriteTimeFunction · 0.95
WriteIntfMethod · 0.95
TestUnmarshalJSONFunction · 0.95

Calls 2

requireMethod · 0.95
putUnixFunction · 0.85

Tested by 11

TestReadTimeBytesFunction · 0.76
BenchmarkSkipBytesFunction · 0.76
TestTimeFunction · 0.76
BenchmarkSkipFunction · 0.76
TestCopyNextFunction · 0.76
TestWriteTimeFunction · 0.76
BenchmarkWriteTimeFunction · 0.76
TestUnmarshalJSONFunction · 0.76