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:
parent
1a75286240
commit
213daa1e46
6 changed files with 45 additions and 7 deletions
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue