From 5b02dfa53f14e4345467cd6abcdd19c8e981b95c Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 22 Jun 2024 16:19:48 +0200 Subject: [PATCH] jsontime: use struct tags instead of setting default format. Some other package (antelope-go in this case) also sets the default format and therefore it clashes with our code. --- api/message/json/codec.go | 3 ++- api/message/types.go | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/message/json/codec.go b/api/message/json/codec.go index d04e103..7024883 100644 --- a/api/message/json/codec.go +++ b/api/message/json/codec.go @@ -18,7 +18,8 @@ func createCodec() message.Codec { func init() { // Set timeformat used by SHIP api - jsontime.SetDefaultTimeFormat("2006-01-02T15:04:05.000", time.UTC) + jsontime.AddTimeFormatAlias("ship", "2006-01-02T15:04:05.000") + jsontime.AddLocaleAlias("ship", time.UTC) // Register the json codec. message.RegisterCodec("json", createCodec()) diff --git a/api/message/types.go b/api/message/types.go index b012b79..98bee44 100644 --- a/api/message/types.go +++ b/api/message/types.go @@ -24,7 +24,7 @@ type AccountAuthSequence struct { type TransactionTrace struct { ID string `json:"id" msgpack:"id"` BlockNum uint32 `json:"blocknum" msgpack:"blocknum"` - Timestamp time.Time `json:"blocktimestamp" msgpack:"blocktimestamp"` + Timestamp time.Time `json:"blocktimestamp" msgpack:"blocktimestamp" time_format:"ship" time_location:"ship"` Status string `json:"status" msgpack:"status"` CPUUsageUS uint32 `json:"cpu_usage_us" msgpack:"cpu_usage_us"` NetUsageWords uint32 `json:"net_usage_words" msgpack:"net_usage_words"` @@ -54,7 +54,7 @@ type ActionTrace struct { BlockNum uint32 `json:"blocknum" msgpack:"blocknum"` - Timestamp time.Time `json:"blocktimestamp" msgpack:"blocktimestamp"` + Timestamp time.Time `json:"blocktimestamp" msgpack:"blocktimestamp" time_format:"ship" time_location:"ship"` Receipt *ActionReceipt `json:"receipt,omitempty" msgpack:"receipt"` @@ -96,7 +96,7 @@ type TableDeltaRow struct { type TableDelta struct { BlockNum uint32 `json:"blocknum" msgpack:"blocknum"` - Timestamp time.Time `json:"blocktimestamp" msgpack:"blocktimestamp"` + Timestamp time.Time `json:"blocktimestamp" msgpack:"blocktimestamp" time_format:"ship" time_location:"ship"` Name string `json:"name" msgpack:"name"` Rows []TableDeltaRow `json:"rows" msgpack:"rows"` }