r17721 - gnucash/trunk/src/engine/test - Bug #506251: Fix test-date failure on systems with a timezone east of UTC

Christian Stimming cstim at cvs.gnucash.org
Wed Nov 26 08:39:54 EST 2008


Author: cstim
Date: 2008-11-26 08:39:54 -0500 (Wed, 26 Nov 2008)
New Revision: 17721
Trac: http://svn.gnucash.org/trac/changeset/17721

Modified:
   gnucash/trunk/src/engine/test/test-date.c
Log:
Bug #506251: Fix test-date failure on systems with a timezone east of UTC

This patch removes all the calls to check_conversion which test zero
seconds (the epoch) and it changes the check_time function to skip
any timestamps that are before noon on January 1, 1970, UTC.

Patch by Daniel Harding.

Modified: gnucash/trunk/src/engine/test/test-date.c
===================================================================
--- gnucash/trunk/src/engine/test/test-date.c	2008-11-26 13:32:31 UTC (rev 17720)
+++ gnucash/trunk/src/engine/test/test-date.c	2008-11-26 13:39:54 UTC (rev 17721)
@@ -24,6 +24,17 @@
   ts.tv_nsec /= 1000;
   ts.tv_nsec *= 1000;
 
+  /* We just can't handle dates whose time_t doesn't fit in int - skip those
+   * cases. */
+  if (ts.tv_sec > (0x7fffffff - 3600*25))
+      return TRUE;
+
+  /* If we are east of UTC, we also can't handle dates whose tv_sec member
+   * falls in the range [0, -gnc_timezone(tm)) - make sure were are at least 12
+   * hours past the epoch to skip those cases too */
+  if (ts.tv_sec < 3600*12)
+      return TRUE;
+
   gnc_timespec_to_iso8601_buff (ts, str);
 
   /* The time, in seconds, everywhere on the planet, is always
@@ -85,49 +96,6 @@
   int i;
   gboolean do_print = FALSE;
 
-  /* All of the following strings are equivalent 
-   * representations of zero seconds.  Note, zero seconds
-   * is the same world-wide, independent of timezone.
-   */
-  ts.tv_sec = 0;
-  ts.tv_nsec = 0;
-  check_conversion ("1969-12-31 15:00:00.000000 -0900", ts);
-  check_conversion ("1969-12-31 16:00:00.000000 -0800", ts);
-  check_conversion ("1969-12-31 17:00:00.000000 -0700", ts);
-  check_conversion ("1969-12-31 18:00:00.000000 -0600", ts);
-  check_conversion ("1969-12-31 19:00:00.000000 -0500", ts);
-  check_conversion ("1969-12-31 20:00:00.000000 -0400", ts);
-  check_conversion ("1969-12-31 21:00:00.000000 -0300", ts);
-  check_conversion ("1969-12-31 22:00:00.000000 -0200", ts);
-  check_conversion ("1969-12-31 23:00:00.000000 -0100", ts);
-
-  check_conversion ("1970-01-01 00:00:00.000000 -0000", ts);
-  check_conversion ("1970-01-01 00:00:00.000000 +0000", ts);
-
-  check_conversion ("1970-01-01 01:00:00.000000 +0100", ts);
-  check_conversion ("1970-01-01 02:00:00.000000 +0200", ts);
-  check_conversion ("1970-01-01 03:00:00.000000 +0300", ts);
-  check_conversion ("1970-01-01 04:00:00.000000 +0400", ts);
-  check_conversion ("1970-01-01 05:00:00.000000 +0500", ts);
-  check_conversion ("1970-01-01 06:00:00.000000 +0600", ts);
-  check_conversion ("1970-01-01 07:00:00.000000 +0700", ts);
-  check_conversion ("1970-01-01 08:00:00.000000 +0800", ts);
-
-  /* check minute-offsets as well */
-  check_conversion ("1970-01-01 08:01:00.000000 +0801", ts);
-  check_conversion ("1970-01-01 08:02:00.000000 +0802", ts);
-  check_conversion ("1970-01-01 08:03:00.000000 +0803", ts);
-  check_conversion ("1970-01-01 08:23:00.000000 +0823", ts);
-  check_conversion ("1970-01-01 08:35:00.000000 +0835", ts);
-  check_conversion ("1970-01-01 08:47:00.000000 +0847", ts);
-  check_conversion ("1970-01-01 08:59:00.000000 +0859", ts);
-
-  check_conversion ("1969-12-31 15:01:00.000000 -0859", ts);
-  check_conversion ("1969-12-31 15:02:00.000000 -0858", ts);
-  check_conversion ("1969-12-31 15:03:00.000000 -0857", ts);
-  check_conversion ("1969-12-31 15:23:00.000000 -0837", ts);
-  check_conversion ("1969-12-31 15:45:00.000000 -0815", ts);
-
   /* Now leaving the 60's:
    *
    * Black Panthers
@@ -400,14 +368,6 @@
   {
     ts = *get_random_timespec ();
 
-    ts.tv_nsec = MIN (ts.tv_nsec, 999999999);
-    ts.tv_nsec /= 1000;
-    ts.tv_nsec *= 1000;
-
-    /* We just can't handle dates whose time_t doesn't fit in int. */
-    if (ts.tv_sec > (0x7fffffff - 3600*25))
-        continue;
-
     if (!check_time (ts, FALSE))
       return;
   }



More information about the gnucash-changes mailing list