Skip site navigation (1) Skip section navigation (2)

Re: datetime error?

From: Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: datetime error?
Date: 2002-01-03 11:28:40
Message-ID: 20020103122840.A13989@zf.jcu.cz (view raw or flat)
Thread:
Lists: pgsql-hackers
On Wed, Jan 02, 2002 at 11:35:08AM -0500, Tom Lane wrote:
> Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> writes:
> >  I start fix my bug with "YY vs. zero" in formatting.c, and before it
> >  a see current CVS:
> 
> > test=# select to_timestamp('10-10-2001', 'MM-DD-YYYY');
> >       to_timestamp
> > ------------------------
> >  2001-10-10 00:00:00+02
> > (1 row)
> 
> > test=# select to_date('10-10-2001', 'MM-DD-YYYY');
> >   to_date
> > ------------
> >  2001-10-09
> >          ^^
> 
> Hmm, is 2001-10-10 a daylight-savings transition day in your timezone?

 No, it's daylight-savings independent. The interesting thing is that 
 you not see it. I found some things:

 * it not happen for GMT timezone, but for others only (I test 'Japan'
   and 'CET').

 * the difference between to_date and to_timestamp is that to_date use
   the timestamp_date() for conversion. And in the timestamp_date() is
   used timestamp2tm() that output bad 'tm' struct.

   The basic difference is that timestamp2tm() with right output do
   code that call localtime() and timestamp2tm() with bad output skip
   it, because 'tzp' is not defined ("if (tzp != NULL)" in this
   timestamp2tm()).  
 
 
 * and the other thing:

 # select to_date('12-13-1901', 'MM-DD-YYYY');
   to_date
 ------------
  1901-12-13
 (1 row)

 # select to_date('12-14-1901', 'MM-DD-YYYY');
 NOTICE:  timestamp_date: year:1901 mon:12, mday:13
   to_date
 ------------
  1901-12-13
 (1 row)
    
 For 'CET' timezone are all dates before '12-14-1901' right :-)

 IMHO it's timezone problem.

        Karel

-- 
 Karel Zak  <zakkr(at)zf(dot)jcu(dot)cz>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

In response to

Responses

pgsql-hackers by date

Next:From: Zeugswetter Andreas SB SDDate: 2002-01-03 13:02:05
Subject: Re: LWLock contention: I think I understand the problem
Previous:From: Thomas SwanDate: 2002-01-03 09:19:29
Subject: Re: Updated TODO item

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group