Skip to content

Commit

Permalink
Make the beheavior of getting record time same with the C code `flb_t…
Browse files Browse the repository at this point in the history
  • Loading branch information
yewei committed Feb 24, 2022
1 parent 0be1ffb commit b8272c4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion output/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package output
import (
"C"
"encoding/binary"
"math"
"reflect"
"time"
"unsafe"
Expand Down Expand Up @@ -82,7 +83,17 @@ func GetRecord(dec *FLBDecoder) (ret int, ts interface{}, rec map[interface{}]in
return -2, 0, nil
}

t := slice.Index(0).Interface()
var t interface{}
switch ts := slice.Index(0).Interface().(type) {
case uint64:
t = FLBTime{time.Unix(int64(ts), 0)}
case float64:
secs, frac := math.Modf(ts)
t = FLBTime{time.Unix(int64(secs), int64(frac*1000_000_000))}
default:
t = ts
}

data := slice.Index(1)

map_data := data.Interface().(map[interface{}]interface{})
Expand Down

0 comments on commit b8272c4

Please sign in to comment.