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