Skip to content

Commit

Permalink
Ensure all runtime 'os' module time functions default to UTC timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
zyro committed Oct 5, 2017
1 parent 87fab29 commit e3cb888
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [keep a changelog](http://keepachangelog.com/) and this p
- Haystack leaderboard record listings now return correct results around both sides of the pivot record.
- Haystack leaderboard record listings now return a complete page even when the pivot record is at the end of the leaderboard.
- CRON expression runtime function now correctly uses UTC as the timezone for input timestamps.
- Ensure all runtime 'os' module time functions default to UTC timezone.

## [1.0.2] - 2017-09-29
### Added
Expand Down
8 changes: 4 additions & 4 deletions server/runtime_oslib.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func osDiffTime(L *lua.LState) int {
}

func osDate(L *lua.LState) int {
t := time.Now()
t := time.Now().UTC()
cfmt := "%c"
if L.GetTop() >= 1 {
cfmt = L.CheckString(1)
Expand Down Expand Up @@ -107,7 +107,7 @@ func osDate(L *lua.LState) int {

func osTime(L *lua.LState) int {
if L.GetTop() == 0 {
L.Push(lua.LNumber(time.Now().Unix()))
L.Push(lua.LNumber(time.Now().UTC().Unix()))
} else {
tbl := L.CheckTable(1)
sec := getIntField(L, tbl, "sec", 0)
Expand All @@ -117,12 +117,12 @@ func osTime(L *lua.LState) int {
month := getIntField(L, tbl, "month", -1)
year := getIntField(L, tbl, "year", -1)
isdst := getBoolField(L, tbl, "isdst", false)
t := time.Date(year, time.Month(month), day, hour, min, sec, 0, time.Local)
t := time.Date(year, time.Month(month), day, hour, min, sec, 0, time.UTC)
// TODO dst
if false {
print(isdst)
}
L.Push(lua.LNumber(t.Unix()))
L.Push(lua.LNumber(t.UTC().Unix()))
}
return 1
}

0 comments on commit e3cb888

Please sign in to comment.