From 9970982e15fa8da3a408fd19ac5f150a81bc9e11 Mon Sep 17 00:00:00 2001 From: Matej Sladek Date: Sun, 10 Dec 2017 00:14:19 +0000 Subject: [PATCH] Add MarshalJSON function for correctly interpreting timestamp of kinesis event --- service/lambda/runtime/event/kinesisstreamsevt/decoder.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service/lambda/runtime/event/kinesisstreamsevt/decoder.go b/service/lambda/runtime/event/kinesisstreamsevt/decoder.go index 921a704..616710f 100644 --- a/service/lambda/runtime/event/kinesisstreamsevt/decoder.go +++ b/service/lambda/runtime/event/kinesisstreamsevt/decoder.go @@ -42,6 +42,12 @@ func (t *timestamp) UnmarshalJSON(data []byte) error { return nil } +func (r *timestamp) MarshalJSON() ([]byte, error) { + secf := float64(r.UnixNano())/float64(time.Second) + sec := strconv.FormatFloat(secf, 'f', 3, 64) + return []byte(sec), nil +} + type jsonRecord struct { *recordAlias ApproximateArrivalTimestamp timestamp