summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2006-06-20 16:37:43 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2006-06-20 16:37:43 +0000
commit1f536d2f1233ede8ef7b205864e72e8ea233c97e (patch)
treeb643f82c38eed463350300c59f382027a835b4d1
parentde6a4865a0612d49e0bad5777156aaa3b5cadb09 (diff)
downloadglib-1f536d2f1233ede8ef7b205864e72e8ea233c97e.tar.gz
Fix an off-by-2 error in the leap year calculation. (#344905, Dan Winship)
2006-06-20 Matthias Clasen <mclasen@redhat.com> * glib/gtimer.c (mktime_utc): Fix an off-by-2 error in the leap year calculation. (#344905, Dan Winship) * tests/testglib.c (main): Change the test data for the g_time_val_from_iso8601 tests to expose an off-by-2 error in the leap year calculation.
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.pre-2-127
-rw-r--r--glib/gtimer.c2
-rw-r--r--tests/testglib.c8
4 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8db738e16..28c164aca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2006-06-20 Matthias Clasen <mclasen@redhat.com>
+ * glib/gtimer.c (mktime_utc): Fix an off-by-2 error
+ in the leap year calculation. (#344905, Dan Winship)
+
+ * tests/testglib.c (main): Change the test data for
+ the g_time_val_from_iso8601 tests to expose an off-by-2
+ error in the leap year calculation.
+
* configure.in: Bump version
* === Released 2.11.4 ===
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 8db738e16..28c164aca 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -1,5 +1,12 @@
2006-06-20 Matthias Clasen <mclasen@redhat.com>
+ * glib/gtimer.c (mktime_utc): Fix an off-by-2 error
+ in the leap year calculation. (#344905, Dan Winship)
+
+ * tests/testglib.c (main): Change the test data for
+ the g_time_val_from_iso8601 tests to expose an off-by-2
+ error in the leap year calculation.
+
* configure.in: Bump version
* === Released 2.11.4 ===
diff --git a/glib/gtimer.c b/glib/gtimer.c
index 402bee535..69b49571a 100644
--- a/glib/gtimer.c
+++ b/glib/gtimer.c
@@ -333,7 +333,7 @@ mktime_utc (struct tm *tm)
retval += (tm->tm_year - 68) / 4;
retval += days_before[tm->tm_mon] + tm->tm_mday - 1;
- if (tm->tm_year % 4 == 2 && tm->tm_mon < 2)
+ if (tm->tm_year % 4 == 0 && tm->tm_mon < 2)
retval -= 1;
retval = ((((retval * 24) + tm->tm_hour) * 60) + tm->tm_min) * 60 + tm->tm_sec;
diff --git a/tests/testglib.c b/tests/testglib.c
index 0aadec72a..0a846653c 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -1178,10 +1178,10 @@ main (int argc,
g_timer_destroy(timer);
g_timer_destroy(timer2);
-#define REF_SEC_UTC 343737360
-#define REF_STR_UTC "1980-11-22T10:36:00Z"
-#define REF_STR_CEST "1980-11-22T12:36:00+02:00"
-#define REF_STR_EST "1980-11-22T05:36:00-05:00"
+#define REF_SEC_UTC 320063760
+#define REF_STR_UTC "1980-02-22T10:36:00Z"
+#define REF_STR_CEST "1980-02-22T12:36:00+02:00"
+#define REF_STR_EST "1980-02-22T05:36:00-05:00"
g_print ("checking g_time_val_from_iso8601...\n");
ref_date.tv_sec = REF_SEC_UTC;