lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On OS X, strftime supports the %s format, resulting in the number of seconds
since the epoch.

The attached small diff makes this usable on OS X using os.date('%s')

Before:

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> print(os.date("%s:%M:%H %d/%m/%Y"))
stdin:1: bad argument #1 to 'date' (invalid conversion specifier '%s:%M:%H %d/%m/%Y')

With the patch applied:

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> print(os.date("%s:%M:%H %d/%m/%Y"))
1469707450:04:14 28/07/2016

I don't know if %s is in ISO C 99 or POSIX, but OS X certainly supports it.

Attachment: loslib.diff
Description: Binary data