MCPcopy Create free account
hub / github.com/francoispqt/gojay / TimeKey

Method TimeKey

encode_time.go:34–51  ·  view source on GitHub ↗

TimeKey adds an *time.Time to be encoded with the given format, must be used inside an object as it will encode a key

(key string, t *time.Time, format string)

Source from the content-addressed store, hash-verified

32
33// TimeKey adds an *time.Time to be encoded with the given format, must be used inside an object as it will encode a key
34func (enc *Encoder) TimeKey(key string, t *time.Time, format string) {
35 if enc.hasKeys {
36 if !enc.keyExists(key) {
37 return
38 }
39 }
40 enc.grow(10 + len(key))
41 r := enc.getPreviousRune()
42 if r != '{' {
43 enc.writeTwoBytes(',', '"')
44 } else {
45 enc.writeByte('"')
46 }
47 enc.writeStringEscape(key)
48 enc.writeBytes(objKeyStr)
49 enc.buf = t.AppendFormat(enc.buf, format)
50 enc.writeByte('"')
51}
52
53// AddTime adds an *time.Time to be encoded with the given format, must be used inside a slice or array encoding (does not encode a key)
54func (enc *Encoder) AddTime(t *time.Time, format string) {

Callers 7

AddTimeKeyMethod · 0.95
MarshalJSONObjectMethod · 0.80
MarshalJSONObjectMethod · 0.80
MarshalJSONObjectMethod · 0.80
MarshalJSONObjectMethod · 0.80
MarshalJSONObjectMethod · 0.80
MarshalJSONObjectMethod · 0.80

Calls 7

keyExistsMethod · 0.95
growMethod · 0.95
getPreviousRuneMethod · 0.95
writeTwoBytesMethod · 0.95
writeByteMethod · 0.95
writeStringEscapeMethod · 0.95
writeBytesMethod · 0.95

Tested by 1

MarshalJSONObjectMethod · 0.64