[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua how to get current and previous day
- From: Natanael Copa <natanael.copa@...>
- Date: Wed, 15 Sep 2010 13:59:54 +0200
On Tue, Sep 14, 2010 at 4:36 PM, Tony Finch <email@example.com> wrote:
> On Tue, 14 Sep 2010, Natanael Copa wrote:
>> On Tue, Sep 14, 2010 at 3:10 PM, Ted Unangst <firstname.lastname@example.org> wrote:
>> > Option 1:
>> > now = os.time()
>> > yesterday = now - 3600*24
>> > print(os.date("...", yesterday))
>> This might give you weird bugs once in a while as it wrongly assumes
>> that a day is always 3600 * 24 hours. You need take leap years and
>> leap seconds in consideration.
> Leap years never affect the length of any days. POSIX time gives every day
> 86400 seconds regardless of leap seconds.
You are of course right about this. The thing i got bitten by once was
daylight saving when time functions returned local time instead of
UTC. But that was PHP on windows.
Its good to be aware of that a day is not always 86400 seconds though.