Fix console formatter for timestampunixnano (#502)
Co-authored-by: Ted Lilley <ted.lilley@digi.com>
This commit is contained in:
parent
e3027a5732
commit
5bdc93f7eb
16
console.go
16
console.go
|
@ -348,15 +348,19 @@ func consoleDefaultFormatTimestamp(timeFormat string, noColor bool) Formatter {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t = tt.String()
|
t = tt.String()
|
||||||
} else {
|
} else {
|
||||||
var sec, nsec int64 = i, 0
|
var sec, nsec int64
|
||||||
|
|
||||||
switch TimeFieldFormat {
|
switch TimeFieldFormat {
|
||||||
case TimeFormatUnixMs:
|
case TimeFormatUnixNano:
|
||||||
nsec = int64(time.Duration(i) * time.Millisecond)
|
sec, nsec = 0, i
|
||||||
sec = 0
|
|
||||||
case TimeFormatUnixMicro:
|
case TimeFormatUnixMicro:
|
||||||
nsec = int64(time.Duration(i) * time.Microsecond)
|
sec, nsec = 0, int64(time.Duration(i)*time.Microsecond)
|
||||||
sec = 0
|
case TimeFormatUnixMs:
|
||||||
|
sec, nsec = 0, int64(time.Duration(i)*time.Millisecond)
|
||||||
|
default:
|
||||||
|
sec, nsec = i, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
ts := time.Unix(sec, nsec)
|
ts := time.Unix(sec, nsec)
|
||||||
t = ts.Format(timeFormat)
|
t = ts.Format(timeFormat)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue