Implement Lua built-in function os.difftime (#1367)

* Implement Lua built-in function os.difftime

* Test os.difftime

---------

Co-authored-by: Zef Hemel <zef@zef.me>
This commit is contained in:
Lennart Ochel
2025-05-04 20:53:48 +02:00
committed by GitHub
co-authored by Zef Hemel
parent c49679c37f
commit 1cda87318b
2 changed files with 13 additions and 0 deletions
+5
View File
@@ -10,6 +10,11 @@ assert(os.date("%Y-%m-%d", os.time({ year = 2020, month = 1, day = 1 })) == "202
-- Week calculations
assert(os.date("%U %V %W", os.time({ year = 2051, month = 1, day = 1 })) == "01 52 00")
local t = os.time()
assert(os.difftime(t+10, t) == 10)
assert(os.difftime(t, t+10) == -10)
assert(os.difftime(t, t) == 0)
assert(os.date("%U %V %W", os.time({ year = 2024, month = 1, day = 7 })) == "01 01 01")
assert(os.date("%U %V %W", os.time({ year = 2025, month = 1, day = 5 })) == "01 01 00")
assert(os.date("%U %V %W", os.time({ year = 2025, month = 1, day = 6 })) == "01 02 01")