to_char function has Daylight Savings Bug

From: Dana Burd <DBurd(at)cpr(dot)org>
To: "'pgsql-bugs(at)postgresql(dot)org'" <pgsql-bugs(at)postgresql(dot)org>
Subject: to_char function has Daylight Savings Bug
Date: 2003-05-15 15:23:25
Message-ID: 893CF1EC58DAD211A2C00060089BB15D8E044B@colorado
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

to_char(timestamp, 'SSSS') has a Daylight Savings bug. It includes the
missing 2am hour in it's "seconds from midnight count" for DST begin day
(4/6/2003), and does not include the extra hour for DST end day
(10/26/2003).

both seconds1 and seconds2 below should be 7200. Note 4/6/2003 is start of
daylight savings for MST7MDT.

select '4/6/2003 3:00:00'::timestamp,
'4/6/2003 00:00:00'::timestamp,
to_char('4/6/2003 3:00:00'::timestamp,'SSSS') AS seconds1,
trunc(extract(epoch from '4/6/2003 3:00:00'::timestamp)-
extract(epoch from '4/6/2003 00:00:00'::timestamp)) AS
seconds2;

timestamptz | timestamptz | seconds1 | seconds2
------------------------+------------------------+----------+----------
2003-04-06 03:00:00-06 | 2003-04-06 00:00:00-07 | 10800 | 7200
(1 row)

Included explicit TZ info, gives the same.

select '4/6/2003 3:00:00 MDT'::timestamp,
'4/6/2003 00:00:00 MST'::timestamp,
to_char('4/6/2003 3:00:00 MDT'::timestamp,'SSSS') AS seconds1,
trunc(extract(epoch from '4/6/2003 3:00:00 MDT'::timestamp)-
extract(epoch from '4/6/2003 00:00:00 MST'::timestamp)) AS
seconds2;

timestamptz | timestamptz | seconds1 | seconds2
------------------------+------------------------+----------+----------
2003-04-06 03:00:00-06 | 2003-04-06 00:00:00-07 | 10800 | 7200
(1 row)

VERSION

% psql -V
psql (PostgreSQL) 7.2.3

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2003-05-15 16:12:42 Re: PL/PgSQL Create/Drop Table Issue
Previous Message vganapathy 2003-05-15 12:05:53 Connection to the database fails