Moved json time formatting

This commit is contained in:
tidwall 2018-08-02 17:36:18 -07:00
parent 632b0ebf63
commit 39d44980c5
2 changed files with 13 additions and 11 deletions

View File

@ -25,17 +25,6 @@ func FenceMatch(hookName string, sw *scanWriter, fence *liveFenceSwitches, metas
}
return nmsgs
}
func appendJSONTimeFormat(b []byte, t time.Time) []byte {
b = append(b, '"')
b = t.AppendFormat(b, "2006-01-02T15:04:05.999999999Z07:00")
b = append(b, '"')
return b
}
func jsonTimeFormat(t time.Time) string {
var b []byte
b = appendJSONTimeFormat(b, t)
return string(b)
}
func appendHookDetails(b []byte, hookName string, metas []FenceMeta) []byte {
if len(hookName) > 0 {
b = append(b, `,"hook":`...)

View File

@ -42,6 +42,19 @@ func jsonString(s string) string {
return string(b)
}
func appendJSONTimeFormat(b []byte, t time.Time) []byte {
b = append(b, '"')
b = t.AppendFormat(b, "2006-01-02T15:04:05.999999999Z07:00")
b = append(b, '"')
return b
}
func jsonTimeFormat(t time.Time) string {
var b []byte
b = appendJSONTimeFormat(b, t)
return string(b)
}
func (c *Controller) cmdJget(msg *server.Message) (resp.Value, error) {
start := time.Now()