Hi all,

This seems like a bug...

prova=> select date '1941-01-01' + interval '1 year';
?column?
----------------------
1942-01-01 00:00:00+02
(1 row)

prova=> select date '1942-01-01' + interval '1 year';
?column?
----------------------
1942-12-31 23:00:00+01  <---------????????????????
(1 row)

prova=> select date '1943-01-01' + interval '1 year';
?column?
----------------------
1944-01-01 00:00:00+01
(1 row)

Any ideas?
--
- Jose' -

"No other success in life can compensate for failure in the home" (David
O. McKay)



Mon, 08 Mar 1999 10:16:24 +0100
"jose' soares" <sferac@bo.nettuno.it>
What's happened with 1942
"jose' soares" <sferac@bo.nettuno.it> writes:
> prova=> select date '1941-01-01' + interval '1 year';
> ?column?
> ----------------------
> 1942-01-01 00:00:00+02
> (1 row)

> prova=> select date '1942-01-01' + interval '1 year';
> ?column?
> ----------------------
> 1942-12-31 23:00:00+01  <---------????????????????
> (1 row)

Note the transition from timezone "+02" to "+01" above.  You're probably
looking at an artifact of the year-round daylight savings time that (IIRC)
some nations used during the war.  Or at least some kind of change in
local timezone or DST rules that year.

Thomas would have a better idea about this than I do, but I'm betting that
the date-plus-interval operator thinks that a "one year" interval means
"365 (or 366 in leap year) times 24 hours", rather than "same local time
on the same nominal date next year".  I seem to recall discussions about
exactly what "date plus 1 day" means when crossing a daylight-savings-time
boundary, for example.

			regards, tom lane

Mon, 08 Mar 1999 10:32:04 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] What's happened with 1942 
> > prova=> select date '1942-01-01' + interval '1 year';
> > ?column?
> > ----------------------
> > 1942-12-31 23:00:00+01  <---------????????????????
> > (1 row)

It is as Tom says:

postgres=> select date '1942-01-01' + interval '1 year';
?column?
----------------------------
Fri Jan 01 00:00:00 1943 GMT
(1 row)

$ setenv PGTZ PST8PDT

postgres=> select date '1942-01-01' + interval '1 year';
?column?
----------------------------
Fri Jan 01 01:00:00 1943 PWT
(1 row)

We seem to have had a timezone adjustment for that year here too. But it
is in your timezone database, not inside of Postgres. Really...

> Thomas would have a better idea about this than I do, but I'm betting 
> that the date-plus-interval operator thinks that a "one year" interval 
> means "365 (or 366 in leap year) times 24 hours", rather than "same 
> local time on the same nominal date next year".  I seem to recall 
> discussions about exactly what "date plus 1 day" means when crossing a 
> daylight-savings-time boundary, for example.

Actually, I'm pretty sure that it adds one to the year in a tm
structure. But Jose's local time zone changed across that year, and the
calculations are done in GMT, then "rotated" back to local time, which
reflects that new zone definition.

You can use zdump to look at the time zone definitions. What time zone
are you using Jose'?

                      - Tom

Tue, 09 Mar 1999 03:45:57 +0000
"Thomas G. Lockhart" <lockhart@alumni.caltech.edu>
Re: [HACKERS] What's happened with 1942