Thread: Date/time fixes for HAVE_TM_ZONE platforms

Date/time fixes for HAVE_TM_ZONE platforms

From
"Thomas G. Lockhart"
Date:
Here are some patches which fix the recently reported date/time problems
on linux/glibc2 machines. Note that these will also fix any machine
which "tests positive" for HAVE_TM_ZONE, which might include SunOS and
xBSD machines.

The symptom can be demonstrated by the following query:

  select datetime('2000-01-01'::date);

which, if there is a problem, will return a time away from midnight.
Note that your time zone must be set to something other than GMT for
this test to be meaningful.

Thanks Oleg for being persistant!

                     - Tom*** ../src/backend/utils/adt/datetime.c.orig    Tue Sep  1 03:25:54 1998
--- ../src/backend/utils/adt/datetime.c    Thu Dec 31 16:19:56 1998
***************
*** 339,345 ****
   *    and then convert again to try to get the time zones correct.
   */
  static int
! date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn)
  {
      struct tm  *tx;
      time_t        utime;
--- 339,345 ----
   *    and then convert again to try to get the time zones correct.
   */
  static int
! date2tm(DateADT dateVal, int *tzp, struct tm *tm, double *fsec, char **tzn)
  {
      struct tm  *tx;
      time_t        utime;
***************
*** 357,370 ****

          /* convert to system time */
          utime = ((dateVal + (date2j(2000, 1, 1) - date2j(1970, 1, 1))) * 86400);
!         utime += (12 * 60 * 60);/* rotate to noon to get the right day in
!                                  * time zone */

  #ifdef USE_POSIX_TIME
          tx = localtime(&utime);

  #ifdef DATEDEBUG
! #ifdef HAVE_INT_TIMEZONE
          printf("date2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
                 tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, (double) tm->tm_sec,
                 tzname[0], tzname[1], tx->tm_isdst);
--- 357,374 ----

          /* convert to system time */
          utime = ((dateVal + (date2j(2000, 1, 1) - date2j(1970, 1, 1))) * 86400);
!         /* rotate to noon to get the right day in time zone */
!         utime += (12 * 60 * 60);

  #ifdef USE_POSIX_TIME
          tx = localtime(&utime);

  #ifdef DATEDEBUG
! #if defined(HAVE_TM_ZONE)
!         printf("date2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
!                tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, (double) tm->tm_sec,
!                tx->tm_zone, tx->tm_isdst);
! #elif defined(HAVE_INT_TIMEZONE)
          printf("date2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
                 tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, (double) tm->tm_sec,
                 tzname[0], tzname[1], tx->tm_isdst);
***************
*** 375,395 ****
          tm->tm_mday = tx->tm_mday;
          tm->tm_isdst = tx->tm_isdst;

! #ifdef HAVE_INT_TIMEZONE
!         *tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
!         if (tzn != NULL)
!             *tzn = tzname[(tm->tm_isdst > 0)];
!
! #else                            /* !HAVE_INT_TIMEZONE */
          tm->tm_gmtoff = tx->tm_gmtoff;
          tm->tm_zone = tx->tm_zone;

!         *tzp = (tm->tm_isdst ? (tm->tm_gmtoff - 3600) : tm->tm_gmtoff); /* tm_gmtoff is
!                                                                          * Sun/DEC-ism */
          if (tzn != NULL)
!             *tzn = tm->tm_zone;
  #endif
-
  #else                            /* !USE_POSIX_TIME */
          *tzp = CTimeZone;        /* V7 conventions; don't know timezone? */
          if (tzn != NULL)
--- 379,399 ----
          tm->tm_mday = tx->tm_mday;
          tm->tm_isdst = tx->tm_isdst;

! #if defined(HAVE_TM_ZONE)
          tm->tm_gmtoff = tx->tm_gmtoff;
          tm->tm_zone = tx->tm_zone;

!         /* tm_gmtoff is Sun/DEC-ism */
!         *tzp = -(tm->tm_gmtoff);
!         if (tzn != NULL)
!             *tzn = (char *)tm->tm_zone;
! #elif defined(HAVE_INT_TIMEZONE)
!         *tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
          if (tzn != NULL)
!             *tzn = tzname[(tm->tm_isdst > 0)];
! #else
! #error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
  #endif
  #else                            /* !USE_POSIX_TIME */
          *tzp = CTimeZone;        /* V7 conventions; don't know timezone? */
          if (tzn != NULL)
***************
*** 410,415 ****
--- 414,431 ----
          if (tzn != NULL)
              *tzn = NULL;
      }
+
+ #ifdef DATEDEBUG
+ #if defined(HAVE_TM_ZONE)
+         printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s) dst=%d\n",
+                tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, (double) tm->tm_sec,
+                *tzp, tm->tm_zone, tm->tm_isdst);
+ #elif defined(HAVE_INT_TIMEZONE)
+         printf("date2tm- %d.%02d.%02d %02d:%02d:%02.0f (%d %s %s) dst=%d\n",
+                tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, (double) tm->tm_sec,
+                *tzp, tzname[0], tzname[1], tm->tm_isdst);
+ #endif
+ #endif

      return 0;
  }    /* date2tm() */
*** ../src/backend/utils/adt/dt.c.orig    Thu Oct  8 18:30:07 1998
--- ../src/backend/utils/adt/dt.c    Thu Dec 31 16:19:46 1998
***************
*** 1454,1464 ****
                  tm->tm_year += 1900;
                  tm->tm_mon += 1;

! #ifdef HAVE_INT_TIMEZONE
!                 tz = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
!
! #else                            /* !HAVE_INT_TIMEZONE */
                  tz = -(tm->tm_gmtoff);    /* tm_gmtoff is Sun/DEC-ism */
  #endif

  #else                            /* !USE_POSIX_TIME */
--- 1454,1465 ----
                  tm->tm_year += 1900;
                  tm->tm_mon += 1;

! #if defined(HAVE_TM_ZONE)
                  tz = -(tm->tm_gmtoff);    /* tm_gmtoff is Sun/DEC-ism */
+ #elif defined(HAVE_INT_TIMEZONE)
+                 tz = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
+ #else
+ #error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
  #endif

  #else                            /* !USE_POSIX_TIME */
***************
*** 2414,2429 ****
  #ifdef USE_POSIX_TIME
              tx = localtime(&utime);
  #ifdef DATEDEBUG
! #ifdef HAVE_INT_TIMEZONE
              printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
                     tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, sec,
                     tzname[0], tzname[1], tx->tm_isdst);
  #else
!             printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
!                    tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, sec,
!                    tx->tm_zone, tx->tm_isdst);
  #endif
- #else
  #endif
              tm->tm_year = tx->tm_year + 1900;
              tm->tm_mon = tx->tm_mon + 1;
--- 2415,2431 ----
  #ifdef USE_POSIX_TIME
              tx = localtime(&utime);
  #ifdef DATEDEBUG
! #if defined(HAVE_TM_ZONE)
!             printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s dst=%d\n",
!                    tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, sec,
!                    tx->tm_zone, tx->tm_isdst);
! #elif defined(HAVE_INT_TIMEZONE)
              printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02.0f %s %s dst=%d\n",
                     tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, sec,
                     tzname[0], tzname[1], tx->tm_isdst);
  #else
! #error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
  #endif
  #endif
              tm->tm_year = tx->tm_year + 1900;
              tm->tm_mon = tx->tm_mon + 1;
***************
*** 2442,2459 ****
  #endif
              tm->tm_isdst = tx->tm_isdst;

! #ifdef HAVE_INT_TIMEZONE
!             *tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
!             if (tzn != NULL)
!                 *tzn = tzname[(tm->tm_isdst > 0)];
!
! #else                            /* !HAVE_INT_TIMEZONE */
              tm->tm_gmtoff = tx->tm_gmtoff;
              tm->tm_zone = tx->tm_zone;

              *tzp = -(tm->tm_gmtoff);    /* tm_gmtoff is Sun/DEC-ism */
              if (tzn != NULL)
!                 *tzn = tm->tm_zone;
  #endif

  #else                            /* !USE_POSIX_TIME */
--- 2444,2462 ----
  #endif
              tm->tm_isdst = tx->tm_isdst;

! #if defined(HAVE_TM_ZONE)
              tm->tm_gmtoff = tx->tm_gmtoff;
              tm->tm_zone = tx->tm_zone;

              *tzp = -(tm->tm_gmtoff);    /* tm_gmtoff is Sun/DEC-ism */
              if (tzn != NULL)
!                 *tzn = (char *)tm->tm_zone;
! #elif defined(HAVE_INT_TIMEZONE)
!             *tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
!             if (tzn != NULL)
!                 *tzn = tzname[(tm->tm_isdst > 0)];
! #else
! #error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
  #endif

  #else                            /* !USE_POSIX_TIME */
***************
*** 2488,2494 ****

  #ifdef DATEDEBUG
  #ifdef USE_POSIX_TIME
! #ifdef HAVE_INT_TIMEZONE
      printf("datetime2tm- timezone is %s; offset is %d (%d); daylight is %d\n",
             tzname[tm->tm_isdst != 0], ((tzp != NULL) ? *tzp : 0), CTimeZone, CDayLight);
  #endif
--- 2491,2500 ----

  #ifdef DATEDEBUG
  #ifdef USE_POSIX_TIME
! #if defined(HAVE_TM_ZONE)
!     printf("datetime2tm- timezone is %s; offset is %d\n",
!            tm->tm_zone, ((tzp != NULL) ? *tzp : 0));
! #elif defined(HAVE_INT_TIMEZONE)
      printf("datetime2tm- timezone is %s; offset is %d (%d); daylight is %d\n",
             tzname[tm->tm_isdst != 0], ((tzp != NULL) ? *tzp : 0), CTimeZone, CDayLight);
  #endif
***************
*** 3034,3044 ****
              tm->tm_year += 1900;
              tm->tm_mon += 1;

! #ifdef HAVE_INT_TIMEZONE
!             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
!
! #else                            /* !HAVE_INT_TIMEZONE */
              *tzp = -(tm->tm_gmtoff);    /* tm_gmtoff is Sun/DEC-ism */
  #endif

  #else                            /* !USE_POSIX_TIME */
--- 3040,3051 ----
              tm->tm_year += 1900;
              tm->tm_mon += 1;

! #if defined(HAVE_TM_ZONE)
              *tzp = -(tm->tm_gmtoff);    /* tm_gmtoff is Sun/DEC-ism */
+ #elif defined(HAVE_INT_TIMEZONE)
+             *tzp = ((tm->tm_isdst > 0) ? (timezone - 3600) : timezone);
+ #else
+ #error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
  #endif

  #else                            /* !USE_POSIX_TIME */
***************
*** 4104,4115 ****

  #ifdef DATEDEBUG
  #ifdef USE_POSIX_TIME
! #ifdef HAVE_INT_TIMEZONE
      printf("EncodeDateTime- timezone is %s (%s); offset is %d (%d); daylight is %d (%d)\n",
             *tzn, tzname[0], *tzp, CTimeZone, tm->tm_isdst, CDayLight);
  #else
!     printf("EncodeDateTime- timezone is %s (%s); offset is %ld (%d); daylight is %d (%d)\n",
!            *tzn, tm->tm_zone, (-tm->tm_gmtoff), CTimeZone, tm->tm_isdst, CDayLight);
  #endif
  #else
      printf("EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",
--- 4111,4124 ----

  #ifdef DATEDEBUG
  #ifdef USE_POSIX_TIME
! #if defined(HAVE_TM_ZONE)
!     printf("EncodeDateTime- timezone is %s (%s); offset is %ld (%d); daylight is %d (%d)\n",
!            *tzn, tm->tm_zone, (-tm->tm_gmtoff), CTimeZone, tm->tm_isdst, CDayLight);
! #elif defined(HAVE_INT_TIMEZONE)
      printf("EncodeDateTime- timezone is %s (%s); offset is %d (%d); daylight is %d (%d)\n",
             *tzn, tzname[0], *tzp, CTimeZone, tm->tm_isdst, CDayLight);
  #else
! #error USE_POSIX_TIME is defined but neither HAVE_TM_ZONE or HAVE_INT_TIMEZONE are defined
  #endif
  #else
      printf("EncodeDateTime- timezone is %s (%s); offset is %d; daylight is %d\n",
*** ../src/backend/utils/adt/nabstime.c.orig    Sun Dec 20 17:35:40 1998
--- ../src/backend/utils/adt/nabstime.c    Thu Dec 31 16:19:51 1998
***************
*** 57,63 ****
      if (!HasCTZSet)
      {
  #ifdef USE_POSIX_TIME
! #ifdef HAVE_TM_ZONE
          tm = localtime(&now);

          CTimeZone = -tm->tm_gmtoff;        /* tm_gmtoff is Sun/DEC-ism */
--- 57,63 ----
      if (!HasCTZSet)
      {
  #ifdef USE_POSIX_TIME
! #if defined(HAVE_TM_ZONE)
          tm = localtime(&now);

          CTimeZone = -tm->tm_gmtoff;        /* tm_gmtoff is Sun/DEC-ism */
***************
*** 86,94 ****
          CTimeZone = tb.timezone * 60;
          CDayLight = (tb.dstflag != 0);

!         /*
!          * XXX does this work to get the local timezone string in V7? -
!          * tgl 97/03/18
           */
          strftime(CTZName, MAXTZLEN, "%Z", localtime(&now));
  #endif
--- 86,93 ----
          CTimeZone = tb.timezone * 60;
          CDayLight = (tb.dstflag != 0);

!         /* XXX does this work to get the local timezone string in V7?
!          * - tgl 97/03/18
           */
          strftime(CTZName, MAXTZLEN, "%Z", localtime(&now));
  #endif
***************
*** 136,149 ****
  #endif

  #if defined(DATEDEBUG)
! #if (! defined(HAVE_TM_ZONE)) && defined(HAVE_INT_TIMEZONE)
!     printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s %s dst=%d\n",
!            tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, tx->tm_sec,
!            tzname[0], tzname[1], tx->tm_isdst);
! #else
      printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s dst=%d\n",
             tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, tx->tm_sec,
             tx->tm_zone, tx->tm_isdst);
  #endif
  #endif

--- 135,148 ----
  #endif

  #if defined(DATEDEBUG)
! #if defined(HAVE_TM_ZONE)
      printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s dst=%d\n",
             tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, tx->tm_sec,
             tx->tm_zone, tx->tm_isdst);
+ #elif defined(HAVE_INT_TIMEZONE)
+     printf("datetime2tm- (localtime) %d.%02d.%02d %02d:%02d:%02d %s %s dst=%d\n",
+            tx->tm_year, tx->tm_mon, tx->tm_mday, tx->tm_hour, tx->tm_min, tx->tm_sec,
+            tzname[0], tzname[1], tx->tm_isdst);
  #endif
  #endif

***************
*** 157,163 ****
      tm->tm_sec = tx->tm_sec;
      tm->tm_isdst = tx->tm_isdst;

! #ifdef HAVE_TM_ZONE
      tm->tm_gmtoff = tx->tm_gmtoff;
      tm->tm_zone = tx->tm_zone;

--- 156,162 ----
      tm->tm_sec = tx->tm_sec;
      tm->tm_isdst = tx->tm_isdst;

! #if defined(HAVE_TM_ZONE)
      tm->tm_gmtoff = tx->tm_gmtoff;
      tm->tm_zone = tx->tm_zone;

***************
*** 171,177 ****
          *tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
      if (tzn != NULL)
          strcpy(tzn, tzname[tm->tm_isdst]);
! #else                            /* !HAVE_INT_TIMEZONE */
  #error POSIX time support is broken
  #endif
  #else                            /* ! USE_POSIX_TIME */
--- 170,176 ----
          *tzp = (tm->tm_isdst ? (timezone - 3600) : timezone);
      if (tzn != NULL)
          strcpy(tzn, tzname[tm->tm_isdst]);
! #else
  #error POSIX time support is broken
  #endif
  #else                            /* ! USE_POSIX_TIME */

Re: Date/time fixes for HAVE_TM_ZONE platforms

From
Oleg Broytmann
Date:
Hello!

On Thu, 31 Dec 1998, Thomas G. Lockhart wrote:
> Here are some patches which fix the recently reported date/time problems
[skip]
> Thanks Oleg for being persistant!
  Cannot apply these patches. Which version/snapshot do I need?

Oleg.
----    Oleg Broytmann  National Research Surgery Centre  http://sun.med.ru/~phd/          Programmers don't die, they
justGOSUB without RETURN.
 



Re: Date/time fixes for HAVE_TM_ZONE platforms

From
"Thomas G. Lockhart"
Date:
>    Cannot apply these patches. Which version/snapshot do I need?

The patches are probably for the current development tree, but both
CURRENT and REL6_4 have already had the patches applied. So just refresh
your cvs snapshot if you have that available...


What version of the tree do you have?
                        - Tom


Re: Date/time fixes for HAVE_TM_ZONE platforms

From
Oleg Broytmann
Date:
Hello!

On Mon, 4 Jan 1999, Thomas G. Lockhart wrote:
> What version of the tree do you have?
  I am not postgres hacker, just average user. I am running postgres for
using it (mostly as backend for CGIs). Currently I run 6.4 and do some
experiments with 6.4.1.

> >    Cannot apply these patches. Which version/snapshot do I need?
> 
> The patches are probably for the current development tree, but both
> CURRENT and REL6_4 have already had the patches applied. So just refresh
> your cvs snapshot if you have that available...
  Does this mean 6.4.2 will have it applied?

Oleg.
----    Oleg Broytmann  National Research Surgery Centre  http://sun.med.ru/~phd/          Programmers don't die, they
justGOSUB without RETURN.
 



Re: Date/time fixes for HAVE_TM_ZONE platforms

From
Oleg Broytmann
Date:
Hello!

On Thu, 31 Dec 1998, Thomas G. Lockhart wrote:
> Here are some patches which fix the recently reported date/time problems

Postgres 6.4.2:

template1=> select datetime('1991-10-01', '11:00');
datetime                    
----------------------------
Tue 01 Oct 11:00:00 1991 EET
(1 row)
  Now the last step - timezone. I remember there was broken 6.4.1 that had
correct timezone here...  My timezone is, of course MSK/MSD. Global tzname really is EET, but
tm->tz_name is MSK.

Oleg.
----  Oleg Broytmann     http://members.tripod.com/~phd2/     phd2@earthling.net          Programmers don't die, they
justGOSUB without RETURN.
 



Re: Date/time fixes for HAVE_TM_ZONE platforms

From
"Thomas G. Lockhart"
Date:
> > Here are some patches which fix the date/time problems
> Postgres 6.4.2:
> Now the last step - timezone. I remember there was broken 6.4.1 that 
> had correct timezone here...
>    My timezone is, of course MSK/MSD. Global tzname really is EET, but
> tm->tz_name is MSK.

Yeah, so is mine. You will note that any year other than 1991 behaves as
you expect, and 1991 results are consistant with the Linux timezone
database (see below):

postgres=> select datetime('1991-10-01'::date);
datetime
----------------------------
Mon Sep 30 23:00:00 1991 EET
(1 row)

postgres=> select datetime('1992-10-01'::date);
datetime
----------------------------
Thu Oct 01 00:00:00 1992 MSK
(1 row)

postgres=> select datetime('1990-10-01'::date);
datetime
----------------------------
Mon Oct 01 00:00:00 1990 MSK
(1 row)

Apparently 1991 had something different for timezone handling for Moscow
time. It isn't as dumb as it sounds; in the US in 1973-4 we ran on
daylight savings time through the winter season as an energy
conservation measure:

postgres=> select '1973-02-01'::datetime;
?column?
----------------------------
Thu Feb 01 00:00:00 1973 PST
(1 row)

postgres=> select '1974-02-01'::datetime;
?column?
----------------------------
Fri Feb 01 00:00:00 1974 PDT
(1 row)

Anyway, you can see the feature in the "zic" timezone database:

golem$ zdump -v -c 2000 Europe/Moscow
<snip>
Europe/Moscow  Sat Sep 29 23:00:00 1990 GMT = Sun Sep 30 02:00:00 1990
MSK isdst=0
Europe/Moscow  Sat Mar 30 22:59:59 1991 GMT = Sun Mar 31 01:59:59 1991
MSK isdst=0
Europe/Moscow  Sat Mar 30 23:00:00 1991 GMT = Sun Mar 31 02:00:00 1991
EET DST isdst=1
Europe/Moscow  Sat Sep 28 23:59:59 1991 GMT = Sun Sep 29 02:59:59 1991
EET DST isdst=1
Europe/Moscow  Sun Sep 29 00:00:00 1991 GMT = Sun Sep 29 02:00:00 1991
EET isdst=0
Europe/Moscow  Sat Jan 18 23:59:59 1992 GMT = Sun Jan 19 01:59:59 1992
EET isdst=0
Europe/Moscow  Sun Jan 19 00:00:00 1992 GMT = Sun Jan 19 03:00:00 1992
MSK isdst=0
Europe/Moscow  Sat Mar 28 22:59:59 1992 GMT = Sun Mar 29 01:59:59 1992
MSK isdst=0
Europe/Moscow  Sat Mar 28 23:00:00 1992 GMT = Sun Mar 29 03:00:00 1992
MSD isdst=1
<snip>
                   - Tom


Re: [HACKERS] Re: Date/time fixes for HAVE_TM_ZONE platforms

From
Oleg Broytmann
Date:
Hello!
  I have choosed nice test case, right? :)))  Of course, I knew this before, just completely forgot when I got good
source for zic. I haven't looked into it for a while.  Ok, I'll recreate patch for datetime regression test and submit
it
tomorrow.  Thank you.

On Tue, 5 Jan 1999, Thomas G. Lockhart wrote:
> Yeah, so is mine. You will note that any year other than 1991 behaves as
> you expect, and 1991 results are consistant with the Linux timezone
> database (see below):
> 
> postgres=> select datetime('1991-10-01'::date);
> datetime
> ----------------------------
> Mon Sep 30 23:00:00 1991 EET
> (1 row)
> 
> postgres=> select datetime('1992-10-01'::date);
> datetime
> ----------------------------
> Thu Oct 01 00:00:00 1992 MSK
> (1 row)
> 
> postgres=> select datetime('1990-10-01'::date);
> datetime
> ----------------------------
> Mon Oct 01 00:00:00 1990 MSK
> (1 row)
> 
> Apparently 1991 had something different for timezone handling for Moscow
> time. It isn't as dumb as it sounds; in the US in 1973-4 we ran on
> daylight savings time through the winter season as an energy
> conservation measure:
> 
> postgres=> select '1973-02-01'::datetime;
> ?column?
> ----------------------------
> Thu Feb 01 00:00:00 1973 PST
> (1 row)
> 
> postgres=> select '1974-02-01'::datetime;
> ?column?
> ----------------------------
> Fri Feb 01 00:00:00 1974 PDT
> (1 row)
> 
> Anyway, you can see the feature in the "zic" timezone database:
> 
> golem$ zdump -v -c 2000 Europe/Moscow
> <snip>
> Europe/Moscow  Sat Sep 29 23:00:00 1990 GMT = Sun Sep 30 02:00:00 1990
> MSK isdst=0
> Europe/Moscow  Sat Mar 30 22:59:59 1991 GMT = Sun Mar 31 01:59:59 1991
> MSK isdst=0
> Europe/Moscow  Sat Mar 30 23:00:00 1991 GMT = Sun Mar 31 02:00:00 1991
> EET DST isdst=1
> Europe/Moscow  Sat Sep 28 23:59:59 1991 GMT = Sun Sep 29 02:59:59 1991
> EET DST isdst=1
> Europe/Moscow  Sun Sep 29 00:00:00 1991 GMT = Sun Sep 29 02:00:00 1991
> EET isdst=0
> Europe/Moscow  Sat Jan 18 23:59:59 1992 GMT = Sun Jan 19 01:59:59 1992
> EET isdst=0
> Europe/Moscow  Sun Jan 19 00:00:00 1992 GMT = Sun Jan 19 03:00:00 1992
> MSK isdst=0
> Europe/Moscow  Sat Mar 28 22:59:59 1992 GMT = Sun Mar 29 01:59:59 1992
> MSK isdst=0
> Europe/Moscow  Sat Mar 28 23:00:00 1992 GMT = Sun Mar 29 03:00:00 1992
> MSD isdst=1
> <snip>
> 
>                     - Tom
> 

Oleg.
----  Oleg Broytmann     http://members.tripod.com/~phd2/     phd2@earthling.net          Programmers don't die, they
justGOSUB without RETURN.