[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Unexpected behaviour with os.date("!%s")
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 21 Jul 2014 10:09:34 +0200
s in the header of your e-mail suggests "subtract 7 hours in order to get PST".
BTW (I don't live there) is EST always +9 or is it sometimes different
due to daylight saving?
2014-07-21 10:06 GMT+02:00 Dirk Laurie <dirk.laurie@gmail.com>:
> LuaJIT does exactly the same. So while unexpected,
> the behaviour is not unreasonable.
>
> In fact, "EST+9" seems to suggest "take EST, and add 9 hours it",
> whereas "-0700 (PDT)" a
>
>
> 2014-07-21 7:03 GMT+02:00 Daurnimator <quae@daurnimator.com>:
>> In Lua 5.1, when you have a non-UTC timezone (e.g. set TZ="EST+9")
>> When you run: `os.date("!%s")` it will give you a timestamp doubly-adjusted
>> for your time zone.
>>
>> $ lua5.1 <<< 'print(os.date("!%s",1234567890))'
>> 1234600290
>>
>> This seems to be an unfortunate side effect of how %s is specified:
>>> The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
>>> (TZ)
>>
>> This isn't an issue in Lua 5.2, as
>> http://www.lua.org/source/5.2/loslib.c.html#LUA_STRFTIMEOPTIONS does not
>> include "s"
>>
>> Daurn.