Re: Re: PostgreSQL 7.0.2 Date Miscalculation

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: lockhart(at)fourpalms(dot)org, Robert Hentosh <hentosh(at)io(dot)com>, JayGuerette(at)pobox(dot)com, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Re: PostgreSQL 7.0.2 Date Miscalculation
Date: 2001-04-03 16:48:52
Message-ID: 3AC9FEF4.E563BECD@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane wrote:
>
> Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu> writes:
> >> --- ./results/horology.out Mon Apr 2 17:06:59 2001
> >> SELECT time with time zone '01:30' + interval '02:01' AS "03:31:00-08";
> >> 03:31:00-08
> >> -------------
> >> ! 03:31:00-07
>
> > Hmm. This is just a badly designed regression test (I can say that,
> > since it is probably mine ;)
>
> > I was trying to exercise TIME WITH TIME ZONE with the *implicit* time
> > zone for today. That really won't work in a testable way, since the
> > result varies during the year :(
> What I'm curious about is why I'm not seeing a failure on HPUX. If your
> explanation is right then this test should fail everywhere during
> daylight savings season.

Well, we won't hold up HPUX as a model for "standard behavior", eh? But
I'm not sure why you don't see the behavior. afaik the calculations
involved should be something like (haven't looked it up, but...):

1) interpret TIME WITH TIME ZONE '01:30' as the time with the time zone
appropriate for that hour today. Convert to internal representation as a
time field with an explicit numeric time zone value.

2) interpret INTERVAL '02:01' as an interval. No month/year fields, and
no time zone involved.

3) Add the interval to the time. Both are in units of seconds
internally.

4) Store the time field modulo 86400, pushing it back into a 24 hour
range. Store the time zone field from step (1) into the result.

5) Print result, using only the internal time zone offset.

- Thomas

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2001-04-03 19:09:23 Re: contrib/pg_resetxlog fails to compile under Digital Unix
Previous Message Tom Lane 2001-04-03 16:08:06 Re: Re: PostgreSQL 7.0.2 Date Miscalculation