lua-users home
lua-l archive

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


On 13 May 2013 23:22, Brad Jorsch <bjorsch@wikimedia.org> wrote:
> Someone recently made a correction to our copy of the Lua manual for
> Scribunto,[1] changing the range of values for 'sec' from 0-61 to
> 0-59. Which is incorrect, considering that leap seconds do exist, but
> that only gives a range of 0-60. How would os.date return a value of
> 61 for the seconds? Or is that an error in the Lua manual?
>
>  [1]: https://www.mediawiki.org/w/index.php?title=Extension:Scribunto/Lua_reference_manual&diff=688113&oldid=685956
>

os.date gets its values from a `tm` struct filled by either gmtime or
localtime as appropriate. According to [1], the tm_secs member is in
the range 0-61, but [2] says it's in the range 0-60.

It was hard to find a copy of the C89 standard, but the copy at [3]
(section 4.12.1) says it's 0-60; as does the C99(?) standard at [4]
(section 7.23.1).

So it looks like the range should be 0-60.

[1] http://www.cplusplus.com/reference/ctime/tm/
[2] http://en.cppreference.com/w/c/chrono/tm
[3] http://web.archive.org/web/20030222051144/http://home.earthlink.net/~bobbitts/c89.txt
[4] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf