1
0
Fork 0

Add a timezone variable to be set in decoded timestamps

This commit is contained in:
Gregory Eremin 2018-11-18 20:21:28 +01:00
parent f61e0d6e84
commit 36c3d2add1
1 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,9 @@ import (
"time"
)
// Timezone is set for decoded datetime values.
var Timezone = time.UTC
// DecodeYear ...
func DecodeYear(v uint8) uint16 {
return uint16(v) + 1900
@ -66,7 +69,8 @@ func DecodeDatetime(v uint64) string {
int((t%10000)/100),
int(t%100),
0,
time.UTC)}.String()
Timezone,
)}.String()
}
// DecodeDatetime2 ...
@ -113,7 +117,7 @@ func DecodeDatetime2(data []byte, dec uint16) (string, int) {
minute := int((hms >> 6) % (1 << 6))
hour := int((hms >> 12))
return FracTime{time.Date(year, time.Month(month), day, hour, minute, second, int(frac*1000), time.UTC), int(dec)}.String(), n
return FracTime{time.Date(year, time.Month(month), day, hour, minute, second, int(frac*1000), Timezone), int(dec)}.String(), n
}
// DecodeTime2 ...