[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kdecore
From: Hans Petter Bieker <bieker () kde ! org>
Date: 2003-08-29 6:38:40
[Download RAW message or body]
CVS commit by bieker:
* hndays is a bit broken with leap years..., will try to fix that later.
* setYMD should now work with leap years.
* removed jflg..
M +23 -15 kcalendarsystemhebrew.cpp 1.31
--- kdelibs/kdecore/kcalendarsystemhebrew.cpp #1.30:1.31
@@ -25,6 +25,4 @@
#include "kcalendarsystemhebrew.h"
-static int jflg = 0; // ### HPB Remove this!?!?
-
static int hebrewDaysInYear(int y);
static QString num2heb(int num, bool includeMillenium);
@@ -52,4 +50,10 @@ static class h_date * hebrewToGregorian(
d += s;
s = hebrewDaysInYear(y + 1) - s; /* length of year */
+
+ if (s > 365 && m > 6 )
+ {
+ --m;
+ d += 30;
+ }
d += (59 * (m - 1) + 1) / 2; /* regular months */
/* special cases */
@@ -59,15 +63,12 @@ static class h_date * hebrewToGregorian(
d--;
// ### HPB: Broken in leap years
- if (s > 365 && m > 6) /* leap year */
- d += 30;
+ //if (s > 365 && m > 6) /* leap year */
+ // d += 30;
d -= 6002;
- if (!jflg) { /* compute century */
+
y = (d + 36525) * 4 / 146097 - 1;
d -= y / 4 * 146097 + (y % 4) * 36524;
y *= 100;
- } else {
- d += 2;
- y = 0;
- }
+
/* compute year */
s = (d + 366)*4/1461-1;
@@ -102,5 +103,4 @@ static class h_date * gregorianToHebrew(
d += 365*y + y/4 + 367*m/12 + 5968;
/* Gregorian calendar */
- if (!jflg)
d -= y/100-y/400-2;
h.hd_dw = (d + 1) % 7;
@@ -479,7 +479,15 @@ int KCalendarSystemHebrew::daysInMonth(c
}
-// Ok
+// ### HPB: This is incorrect
int KCalendarSystemHebrew::hndays(int mon, int year) const
{
+ if ( is_leap_year(year) )
+ if ( mon == 6 )
+ mon = 13;
+ else if ( mon == 7 )
+ mon = 14;
+ else
+ --mon;
+
if( mon == 8 /*IYYAR*/ || mon == 10 /*TAMUZ*/ ||
mon == 12 /*ELUL*/ || mon == 4 /*TEVET*/ ||
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic