Skip to content

Commit

Permalink
Add a timezone variable to be set in decoded timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Eremin committed Nov 18, 2018
1 parent 94ec0f7 commit c7e63e2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mysql/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,7 +69,8 @@ func DecodeDatetime(v uint64) string {
int((t%10000)/100),
int(t%100),
0,
time.UTC)}.String()
Timezone,
)}.String()
}

// DecodeDatetime2 ...
Expand Down Expand Up @@ -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 ...
Expand Down

0 comments on commit c7e63e2

Please sign in to comment.