[Kstars-devel] kdeedu/libkdeedu/extdate

Jason Harris kstars at 30doradus.org
Thu Aug 19 06:09:41 CEST 2004


CVS commit by harris: 

Fix highlighting of the selected date in the ExtDatePicker widget 
for years < 2000.  The highlighted date was off by one week because of a 
bug in ExtDate::dayOfWeek().  

Also, make ExtDate::addMonths() more robust.

This time I actually committed to the correct branch...

(TO BE BACKPORTED)

CCMAIL: kstars-devel at kde.org


  M +9 -3      extdatetime.cpp   1.9


--- kdeedu/libkdeedu/extdate/extdatetime.cpp  #1.8:1.9
@@ -281,4 +281,5 @@ int ExtDate::dayOfWeek() const
         //JD 2451545 (01 Jan 2000) was a Saturday, which is dayOfWeek=6.
         int a_day = (( jd() - 2451545 + 6 ) % 7);
+        if ( a_day < 0 ) a_day += 7;
         return (a_day == 0) ? 7 : a_day;
 }
@@ -517,7 +518,12 @@ ExtDate ExtDate::addDays( int days ) con
 ExtDate  ExtDate::addMonths( int months ) const
 {
-        int     a_month = month() + months;
-        int     a_year = year() + (a_month - 1)/12;     // month : [1..12]
-        a_month  = 1 + (a_month -1) % 12;
+        int a_month = month() + months%12;
+        int a_year  = year()  + int(months/12);
+
+        while ( a_month < 1 ) {
+                a_month += 12;
+                a_year--;
+        }
+
         return ExtDate(a_year, a_month, day());
 }




More information about the Kstars-devel mailing list