fix(parse): offset parsing when seconds are decimal (#33)

This commit is contained in:
waynec86
2023-09-06 08:41:26 -07:00
committed by GitHub
parent ea9ca801a4
commit b20176ce47
2 changed files with 12 additions and 1 deletions

View File

@@ -72,6 +72,17 @@ describe("Testing the 'date' module", function()
assert(date("1976-W01-1 13:00+01:00")==date(1975,12,29,12))
assert(date("1976-W01-1 0700-0500 ")==date(1975,12,29,12))
-- timezone offset with colon
assert(date("2023-08-22T17:40:23.308574-05:00")==date(2023,08,22,22,40,23.308574000))
-- timezone offset without colon
assert(date("2023-08-22T17:40:23.308574-0500")==date(2023,08,22,22,40,23.308574000))
-- timezone offset without minutes
assert(date("2023-08-22T17:40:23.308574-05")==date(2023,08,22,22,40,23.308574000))
-- timezone offset without colon with positive offset and non-zero minutes
assert(date("2023-08-22T19:40:23.308574+08:45")==date(2023,08,22,10,55,23.308574000))
-- timezone offset without colon with no decimal seconds
assert(date("2023-08-22T19:40:23-09:30")==date(2023,08,23,5,10,23))
local a = date(2006, 8, 13) assert(a == date("Sun Aug 13 2006"))
local b = date("Jun 13 1999") assert(b == date(1999, 6, 13))
local c = date(1234483200) assert(c == date("Feb 13 2009"))