mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
chore(tests): fix toUniversalTime test
This commit is contained in:
parent
ac948b22d9
commit
6ddaecb0ba
1 changed files with 26 additions and 20 deletions
|
@ -1,24 +1,30 @@
|
||||||
local DateTime = require("@lune/DateTime")
|
local DateTime = require("@lune/DateTime")
|
||||||
|
|
||||||
local dateTime = (DateTime.fromIsoDate("2023-08-27T05:54:19Z") :: DateTime.DateTime):toLocalTime()
|
local dateTime = DateTime.fromUnixTimestamp(1693115659):toLocalTime()
|
||||||
|
|
||||||
local expectedDateTimeValues = table.pack(
|
local expectedDateTimeValues = os.date("*t", 1693115659)
|
||||||
string.match(
|
|
||||||
"2023-08-27T11:24:19Z",
|
assert(
|
||||||
"(%d%d%d%d)-?(%d?%d?)-?(%d?%d?)T(%d?%d?):(%d?%d?):(%d?%d?)Z$"
|
dateTime.year == expectedDateTimeValues.year,
|
||||||
|
`expected {dateTime.year} == {expectedDateTimeValues.year}`
|
||||||
)
|
)
|
||||||
|
assert(
|
||||||
|
dateTime.month == expectedDateTimeValues.month,
|
||||||
|
`expected {dateTime.month} == {expectedDateTimeValues.month}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
dateTime.day == expectedDateTimeValues.day,
|
||||||
|
`expected {dateTime.day} == {expectedDateTimeValues.day}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
dateTime.hour == expectedDateTimeValues.hour,
|
||||||
|
`expected {dateTime.hour} == {expectedDateTimeValues.hour}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
dateTime.minute == expectedDateTimeValues.min,
|
||||||
|
`expected {dateTime.minute} == {expectedDateTimeValues.min}`
|
||||||
|
)
|
||||||
|
assert(
|
||||||
|
dateTime.second == expectedDateTimeValues.sec,
|
||||||
|
`expected {dateTime.second} == {expectedDateTimeValues.sec}`
|
||||||
)
|
)
|
||||||
|
|
||||||
local expectedYear = tonumber(expectedDateTimeValues[1])
|
|
||||||
local expectedMonth = tonumber(expectedDateTimeValues[2])
|
|
||||||
local expectedDay = tonumber(expectedDateTimeValues[3])
|
|
||||||
local expectedHour = tonumber(expectedDateTimeValues[4])
|
|
||||||
local expectedMinute = tonumber(expectedDateTimeValues[5])
|
|
||||||
local expectedSecond = tonumber(expectedDateTimeValues[6])
|
|
||||||
|
|
||||||
assert(dateTime.year == expectedYear, `expected {dateTime.year} == {expectedYear}`)
|
|
||||||
assert(dateTime.month == expectedMonth, `expected {dateTime.month} == {expectedMonth}`)
|
|
||||||
assert(dateTime.day == expectedDay, `expected {dateTime.day} == {expectedDay}`)
|
|
||||||
assert(dateTime.hour == expectedHour, `expected {dateTime.hour} == {expectedHour}`)
|
|
||||||
assert(dateTime.minute == expectedMinute, `expected {dateTime.minute} == {expectedMinute}`)
|
|
||||||
assert(dateTime.second == expectedSecond, `expected {dateTime.second} == {expectedSecond}`)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue