Skip to content

Commit

Permalink
[patch] add default location loading logic which load location from T…
Browse files Browse the repository at this point in the history
…Z env variable

Signed-off-by: kpango <kpango@vdaas.org>
  • Loading branch information
kpango committed Nov 18, 2022
1 parent 9a399b7 commit a86aea0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fastime.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"math"
"sync/atomic"
"syscall"
"time"
"unsafe"
)
Expand Down Expand Up @@ -66,6 +67,14 @@ func newFastime() *fastime {
}(),
location: func() *atomic.Value {
av := new(atomic.Value)
tz, ok := syscall.Getenv("TZ")
if ok && tz != "" {
loc, err := time.LoadLocation(tz)
if err == nil {
av.Store(loc)
return av
}
}
av.Store(new(time.Location))
return av
}(),
Expand Down

0 comments on commit a86aea0

Please sign in to comment.