summaryrefslogtreecommitdiffabout
path: root/microkde/kcalendarsystemgregorian.cpp
Unidiff
Diffstat (limited to 'microkde/kcalendarsystemgregorian.cpp') (more/less context) (show whitespace changes)
-rw-r--r--microkde/kcalendarsystemgregorian.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/microkde/kcalendarsystemgregorian.cpp b/microkde/kcalendarsystemgregorian.cpp
index 7c5b62a..cc12b9f 100644
--- a/microkde/kcalendarsystemgregorian.cpp
+++ b/microkde/kcalendarsystemgregorian.cpp
@@ -45,43 +45,43 @@ int KCalendarSystemGregorian::year(const QDate& date) const
45 return date.year(); 45 return date.year();
46} 46}
47 47
48int KCalendarSystemGregorian::monthsInYear( const QDate & ) const 48int KCalendarSystemGregorian::monthsInYear( const QDate & ) const
49{ 49{
50// kdDebug(5400) << "Gregorian monthsInYear" << endl; 50// kdDebug(5400) << "Gregorian monthsInYear" << endl;
51 51
52 return 12; 52 return 12;
53} 53}
54 54
55int KCalendarSystemGregorian::weeksInYear(int year) const 55int KCalendarSystemGregorian::weeksInYear(int year) const
56{ 56{
57#if QT_VERSION >= 300 57#if QT_VERSION >= 0x030000
58 QDate temp; 58 QDate temp;
59 temp.setYMD(year, 12, 31); 59 temp.setYMD(year, 12, 31);
60 60
61 // If the last day of the year is in the first week, we have to check the 61 // If the last day of the year is in the first week, we have to check the
62 // week before 62 // week before
63 if ( temp.weekNumber() == 1 ) 63 if ( temp.weekNumber() == 1 )
64 temp.addDays(-7); 64 temp.addDays(-7);
65 65
66 return temp.weekNumber(); 66 return temp.weekNumber();
67#else 67#else
68 return 52; 68 return 52;
69#endif 69#endif
70} 70}
71 71
72int KCalendarSystemGregorian::weekNumber(const QDate& date, 72int KCalendarSystemGregorian::weekNumber(const QDate& date,
73 int * yearNum) const 73 int * yearNum) const
74{ 74{
75#if QT_VERSION >= 300 75#if QT_VERSION >= 0x030000
76 return date.weekNumber(yearNum); 76 return date.weekNumber(yearNum);
77#else 77#else
78 return 1; 78 return 1;
79#endif 79#endif
80} 80}
81 81
82QString KCalendarSystemGregorian::monthName(const QDate& date, 82QString KCalendarSystemGregorian::monthName(const QDate& date,
83 bool shortName) const 83 bool shortName) const
84{ 84{
85 return monthName(month(date), shortName); 85 return monthName(month(date), shortName);
86} 86}
87 87
@@ -222,39 +222,39 @@ QString KCalendarSystemGregorian::monthNamePossessive(int month,
222bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const 222bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const
223{ 223{
224 // We don't want Qt to add 1900 to them 224 // We don't want Qt to add 1900 to them
225 if ( y >= 0 && y <= 99 ) 225 if ( y >= 0 && y <= 99 )
226 return false; 226 return false;
227 227
228 // QDate supports gregorian internally 228 // QDate supports gregorian internally
229 return date.setYMD(y, m, d); 229 return date.setYMD(y, m, d);
230} 230}
231 231
232QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const 232QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const
233{ 233{
234#if QT_VERSION >= 300 234#if QT_VERSION >= 0x030000
235 return date.addYears(nyears); 235 return date.addYears(nyears);
236#else 236#else
237 int year = date.year() + nyears; 237 int year = date.year() + nyears;
238 int month = date.month(); 238 int month = date.month();
239 int day = date.day(); 239 int day = date.day();
240 QDate newDate( year, month, 1 ); 240 QDate newDate( year, month, 1 );
241 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); 241 if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth();
242 return QDate( year, month, day ); 242 return QDate( year, month, day );
243#endif 243#endif
244} 244}
245 245
246QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const 246QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const
247{ 247{
248#if QT_VERSION >= 300 248#if QT_VERSION >= 0x030000
249 return date.addMonths(nmonths); 249 return date.addMonths(nmonths);
250#else 250#else
251 int month = date.month(); 251 int month = date.month();
252 int nyears; 252 int nyears;
253 if ( nmonths >= 0 ) { 253 if ( nmonths >= 0 ) {
254 month += nmonths; 254 month += nmonths;
255 nyears = ( month - 1 ) / 12; 255 nyears = ( month - 1 ) / 12;
256 month = ( ( month - 1 ) % 12 ) + 1; 256 month = ( ( month - 1 ) % 12 ) + 1;
257 } else { 257 } else {
258 nyears = nmonths / 12; 258 nyears = nmonths / 12;
259 // nmonths += nyears * 12; 259 // nmonths += nyears * 12;
260 nmonths = nmonths % 12; 260 nmonths = nmonths % 12;