lune/tests/datetime/fromLocalTime.luau

42 lines
987 B
Lua
Raw Normal View History

local DateTime = require("@lune/datetime")
local timeValues1 = os.date("*t", 1693049188)
assert(
DateTime.fromLocalTime({
year = timeValues1.year,
month = timeValues1.month,
day = timeValues1.day,
hour = timeValues1.hour,
minute = timeValues1.min,
second = timeValues1.sec,
millisecond = 0,
}).unixTimestamp == 1693049188,
"expected DateTime.fromLocalTime() with DateTimeValues arg to return 1693049188s"
)
print(DateTime.fromLocalTime({
year = 2023,
month = 8,
day = 26,
hour = 16,
minute = 56,
second = 28,
millisecond = 892,
}).unixTimestamp)
local timeValues2 = os.date("*t", 1693049188.892)
assert(
DateTime.fromLocalTime({
year = timeValues2.year,
month = timeValues2.month,
day = timeValues2.day,
hour = timeValues2.hour,
minute = timeValues2.min,
second = timeValues2.sec,
millisecond = 892,
}).unixTimestampMillis == 1693049188892,
"expected DateTime.fromLocalTime() with DateTimeValues arg with millis to return 1693049188892ms"
)