1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-18 04:40:03 +02:00

api/message/json/codec.go: fix timestamps, skip "Z" (always UTC) and use 3 decimals for milliseconds.

This commit is contained in:
Henrik Hautakoski 2023-05-05 09:20:35 +02:00
parent 1a75286240
commit 213daa1e46
6 changed files with 45 additions and 7 deletions

View file

@ -1,14 +1,19 @@
package json
import (
"encoding/json"
"time"
"github.com/eosswedenorg/thalos/api/message"
jsontime "github.com/liamylian/jsontime/v2/v2"
)
var json_codec = jsontime.ConfigWithCustomTimeFormat
func init() {
jsontime.SetDefaultTimeFormat("2006-01-02T15:04:05.000", time.UTC)
message.RegisterCodec("json", message.Codec{
Encoder: json.Marshal,
Decoder: json.Unmarshal,
Encoder: json_codec.Marshal,
Decoder: json_codec.Unmarshal,
})
}