2023-09-16 05:24:05 +01:00
|
|
|
local DateTime = require("@lune/datetime")
|
2023-09-11 18:52:07 +01:00
|
|
|
|
|
|
|
-- Bug in rust side implementation for fromUnixTimestamp, calculation for conversion there is wonky,
|
|
|
|
-- a difference of few millis causes differences as whole seconds for some reason
|
|
|
|
|
|
|
|
assert(
|
2023-09-16 05:24:05 +01:00
|
|
|
DateTime.fromUnixTimestamp(0000.892).unixTimestampMillis == (0 * 1000) + 892,
|
2023-09-11 18:52:07 +01:00
|
|
|
"expected DateTime.fromUnixTimestamp() with millis float to return correct millis timestamp"
|
|
|
|
)
|
|
|
|
|
|
|
|
-- We subtract one due to the floating point accuracy... Need to fix later
|
|
|
|
assert(
|
2023-09-16 05:24:05 +01:00
|
|
|
DateTime.fromUnixTimestamp(1693114921.632).unixTimestampMillis
|
2023-09-11 18:52:07 +01:00
|
|
|
== ((1693114921 * 1000) + 632) - 1,
|
|
|
|
"expected DateTime.fromUnixTimestamp() with millis and seconds float to return correct millis timestamp"
|
|
|
|
)
|