Re: bug in date_part() function in 6.5.2, 7.0.2 - Mailing list pgsql-bugs

From Thomas Lockhart
Subject Re: bug in date_part() function in 6.5.2, 7.0.2
Date
Msg-id 39B87E44.90B3ECFD@alumni.caltech.edu
Whole thread Raw
In response to Re: bug in date_part() function in 6.5.2, 7.0.2  (Karel Zak <zakkr@zf.jcu.cz>)
Responses Re: bug in date_part() function in 6.5.2, 7.0.2  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
> Seems like you could just skip step 3 and call localtime() with fields
> indicating midnight of the specified date.  Then use the complete
> localtime result (don't discard any fields) and you should be OK, no?

Pretty sure this won't work, since the complete localtime result will
not be local midnight, which is the expected result. The problem is that
I don't know what the actual time zone (and DST status) is until *after*
converting from UTC to local. And when the input type is "date" I have
no time zone context to use as a hint.

Rotating to UTC noon solves some problems since converting from UTC to
local time will always stay within the same local calendar day. But it
falls down on the DST transition days, as we've noticed.

I started playing with mktime(), which would seem to be the right thing,
but it isn't clear from my docs that this routine will work without the
time zone fields filled in. Well, no matter what the docs say it seems
to interact badly with my code and I get segfaults a few lines farther
along. I'm poking at it to track down the problem.

                     - Thomas

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Select from array slices doesn't work
Next
From: Tom Lane
Date:
Subject: Re: bug in date_part() function in 6.5.2, 7.0.2