[glib] datetime: Fix a thinko



commit 08877ee0dc61b73978d6e7f46216c9405498dbf8
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Wed Aug 25 23:08:18 2010 +0100

    datetime: Fix a thinko
    
    We need to check if a year is a leap one *after* we increased it with
    the given value, not before.

 glib/gdatetime.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/glib/gdatetime.c b/glib/gdatetime.c
index c7972b4..baf0c5f 100644
--- a/glib/gdatetime.c
+++ b/glib/gdatetime.c
@@ -357,6 +357,8 @@ g_date_time_add_dmy (GDateTime *datetime,
   gint step, i;
   const guint16 *max_days;
 
+  __year += years;
+
   /* subtract one day for leap years */
   if (GREGORIAN_LEAP (__year) && __month == 2)
     {
@@ -364,8 +366,6 @@ g_date_time_add_dmy (GDateTime *datetime,
         __day -= 1;
     }
 
-  __year += years;
-
   /* add months */
   step = months > 0 ? 1 : -1;
   for (i = 0; i < ABS (months); i++)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]