Re: Bug in Time/Date routines - Mailing list pgsql-bugs

From Thomas Lockhart
Subject Re: Bug in Time/Date routines
Date
Msg-id 3A01AFEE.9E8B7115@alumni.caltech.edu
Whole thread Raw
In response to Bug in Time/Date routines  (Moritz Gmelin <moritz.gmelin@gmx.de>)
List pgsql-bugs
> > If you take any other month than October, it is working fine. So
> > 09-01-2000 + 1 month => 10-01-2000.
> regression=# select ('10-01-2000'::timestamp + ('1 month')::timespan);
>         ?column?
> ------------------------
>  2000-10-31 23:00:00-05
> (1 row)
> Thomas, isn't the addition of '1 month' done symbolically in a struct tm?
> I suspect you may have forgotten to set tm_isdst = -1 before invoking
> mktime(), causing it to interpret the time of day on the target date
> as the same DST or not-DST case that applied on the initial date.
> Seems to me that both times should be taken as "local time", so you
> should force mktime() to recompute whether DST is in effect or not.

That particular operation needs mktime() called twice in some cases :(

Once for the input timestamp and once for the intermediate result. I'm
testing a fix now which gives the right result for this particular case.

                   - Tom

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: strange array insertion
Next
From: Lennert Buytenhek
Date:
Subject: waiting for lock?