Diffstat (limited to 'microkde/kcalendarsystemgregorian.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kcalendarsystemgregorian.cpp | 8 |
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 | |||
@@ -33,67 +33,67 @@ KCalendarSystemGregorian::KCalendarSystemGregorian(const KLocale * locale) | |||
33 | : KCalendarSystem(locale) | 33 | : KCalendarSystem(locale) |
34 | { | 34 | { |
35 | kdDebug(5400) << "Created gregorian calendar" << endl; | 35 | kdDebug(5400) << "Created gregorian calendar" << endl; |
36 | } | 36 | } |
37 | 37 | ||
38 | KCalendarSystemGregorian::~KCalendarSystemGregorian() | 38 | KCalendarSystemGregorian::~KCalendarSystemGregorian() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | int KCalendarSystemGregorian::year(const QDate& date) const | 42 | int KCalendarSystemGregorian::year(const QDate& date) const |
43 | { | 43 | { |
44 | // kdDebug(5400) << "Gregorian year..." << endl; | 44 | // kdDebug(5400) << "Gregorian year..." << endl; |
45 | return date.year(); | 45 | return date.year(); |
46 | } | 46 | } |
47 | 47 | ||
48 | int KCalendarSystemGregorian::monthsInYear( const QDate & ) const | 48 | int 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 | ||
55 | int KCalendarSystemGregorian::weeksInYear(int year) const | 55 | int 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 | ||
72 | int KCalendarSystemGregorian::weekNumber(const QDate& date, | 72 | int 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 | ||
82 | QString KCalendarSystemGregorian::monthName(const QDate& date, | 82 | QString 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 | ||
88 | QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const | 88 | QString KCalendarSystemGregorian::monthNamePossessive(const QDate& date, bool shortName) const |
89 | { | 89 | { |
90 | return monthNamePossessive(month(date), shortName); | 90 | return monthNamePossessive(month(date), shortName); |
91 | } | 91 | } |
92 | 92 | ||
93 | QString KCalendarSystemGregorian::monthName(int month, bool shortName) const | 93 | QString KCalendarSystemGregorian::monthName(int month, bool shortName) const |
94 | { | 94 | { |
95 | // kdDebug(5400) << "Gregorian getMonthName" << endl; | 95 | // kdDebug(5400) << "Gregorian getMonthName" << endl; |
96 | 96 | ||
97 | if ( shortName ) | 97 | if ( shortName ) |
98 | switch ( month ) | 98 | switch ( month ) |
99 | { | 99 | { |
@@ -210,63 +210,63 @@ QString KCalendarSystemGregorian::monthNamePossessive(int month, | |||
210 | return locale()->translate("of September"); | 210 | return locale()->translate("of September"); |
211 | case 10: | 211 | case 10: |
212 | return locale()->translate("of October"); | 212 | return locale()->translate("of October"); |
213 | case 11: | 213 | case 11: |
214 | return locale()->translate("of November"); | 214 | return locale()->translate("of November"); |
215 | case 12: | 215 | case 12: |
216 | return locale()->translate("of December"); | 216 | return locale()->translate("of December"); |
217 | } | 217 | } |
218 | 218 | ||
219 | return QString::null; | 219 | return QString::null; |
220 | } | 220 | } |
221 | 221 | ||
222 | bool KCalendarSystemGregorian::setYMD(QDate & date, int y, int m, int d) const | 222 | bool 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 | ||
232 | QDate KCalendarSystemGregorian::addYears(const QDate & date, int nyears) const | 232 | QDate 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 | ||
246 | QDate KCalendarSystemGregorian::addMonths(const QDate & date, int nmonths) const | 246 | QDate 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; |
261 | month += nmonths; | 261 | month += nmonths; |
262 | if ( month <= 0 ) { | 262 | if ( month <= 0 ) { |
263 | month += 12; | 263 | month += 12; |
264 | --nyears; | 264 | --nyears; |
265 | } | 265 | } |
266 | } | 266 | } |
267 | int year = date.year() + nyears; | 267 | int year = date.year() + nyears; |
268 | int day = date.day(); | 268 | int day = date.day(); |
269 | QDate newDate( year, month, 1 ); | 269 | QDate newDate( year, month, 1 ); |
270 | if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); | 270 | if ( day > newDate.daysInMonth() ) day = newDate.daysInMonth(); |
271 | return QDate( year, month, day ); | 271 | return QDate( year, month, day ); |
272 | #endif | 272 | #endif |