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)
| 636 | // heavily on the internal representation used by the |
| 637 | // time package.) |
| 638 | func (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 |