Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit eec97ee

Browse files
committed
Add a fix to a very rare bug on utctime()
1 parent 3b1aa8f commit eec97ee

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/General.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,18 @@ end
237237
* Returns the current time of day, in seconds, on UTC timezone.
238238
*
239239
* @since 0.1.0
240+
* @updated 1.5.1
240241
*
241242
* @returns {number} - UTC time of day in seconds
242243
--]]
243244
function utctime()
244-
return tosec(os.date('!%X'))
245+
local t = os.date('!%X')
246+
247+
-- Apparently os.date('!%X') returns the time with AM/PM appended on some
248+
-- computers; this ignores anything before and after the actual timestamp
249+
t = table.first(t:match('(%d%d:%d%d:%d%d)'))
250+
251+
return tosec(t)
245252
end
246253

247254
--[[

0 commit comments

Comments
 (0)