summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanthosh Thottingal <santhosh.thottingal@gmail.com>2009-01-03 11:07:39 +0530
committerSanthosh Thottingal <santhosh.thottingal@gmail.com>2009-01-03 11:07:39 +0530
commit5c4a38dca38e6d0df0b4e4f2c287b7379f7dabf0 (patch)
treedeb4e7e1744e8f67d49a044c18ad28d602c21c37
parent37be862cde11469b9def77e0123eb8d21fd77f9a (diff)
parentd8be2541d0085081c3cd4265defc3befa7009f5d (diff)
downloadRachana.git-5c4a38dca38e6d0df0b4e4f2c287b7379f7dabf0.tar.gz
Rachana.git-5c4a38dca38e6d0df0b4e4f2c287b7379f7dabf0.tar.xz
Rachana.git-5c4a38dca38e6d0df0b4e4f2c287b7379f7dabf0.zip
Merge branch 'master' of ssh://santhosh@git.sv.gnu.org/srv/git/smc
-rw-r--r--calendar/kde/kdelibs/kdecore/date/kcalendarsystemindic.cpp35
1 files changed, 20 insertions, 15 deletions
diff --git a/calendar/kde/kdelibs/kdecore/date/kcalendarsystemindic.cpp b/calendar/kde/kdelibs/kdecore/date/kcalendarsystemindic.cpp
index 45ec459..9900342 100644
--- a/calendar/kde/kdelibs/kdecore/date/kcalendarsystemindic.cpp
+++ b/calendar/kde/kdelibs/kdecore/date/kcalendarsystemindic.cpp
@@ -255,7 +255,22 @@ QDate KCalendarSystemIndic::addYears( const QDate &date, int nyears ) const
QDate KCalendarSystemIndic::addMonths( const QDate &date, int nmonths ) const
{
- return KCalendarSystem::addMonths( date, nmonths );
+ QDate result = date;
+ int m = month( date );
+ int y = year( date );
+ if ( nmonths < 0 ) {
+ m += 12;
+ y -= 1;
+ }
+ --m; // this only works if we start counting at zero
+ m += nmonths;
+ y += m / 12;
+ m %= 12;
+ ++m;
+
+ setYMD( result, y, m, day( date ) );
+
+ return result;
}
QDate KCalendarSystemIndic::addDays( const QDate &date, int ndays ) const
@@ -286,7 +301,7 @@ int KCalendarSystemIndic::daysInYear( const QDate &date ) const
int KCalendarSystemIndic::daysInMonth( const QDate &date ) const
{
- return KCalendarSystem::daysInMonth( date );
+ return KCalendarSystemSaka::getMonthLength(date.year(),date.month());
}
int KCalendarSystemIndic::daysInWeek( const QDate &date ) const
@@ -297,20 +312,11 @@ int KCalendarSystemIndic::daysInWeek( const QDate &date ) const
int KCalendarSystemIndic::dayOfYear( const QDate &date ) const
{
- //Base class takes the jd of the given date, and subtracts the jd of the first day of that year
- //but in QDate 1 Jan -4713 is not a valid date, so special case it here.
+QDate first;
+ setYMD( first, year( date ), 1, 1 );
- // Don't bother with validity check here, not needed, leave to base class
- if ( year( date ) == -4713 ) {
- QDate secondDayOfYear;
- if ( setDate( secondDayOfYear, -4713, 1, 2 ) ) {
- return ( date.toJulianDay() - secondDayOfYear.toJulianDay() + 2 );
- }
- } else {
- return KCalendarSystem::dayOfYear( date );
- }
+ return first.daysTo( date ) + 1;
- return -1;
}
int KCalendarSystemIndic::dayOfWeek( const QDate &date ) const
@@ -325,7 +331,6 @@ int KCalendarSystemIndic::weekNumber( const QDate &date, int * yearNum ) const
bool KCalendarSystemIndic::isLeapYear( int year ) const
{
- // Use QDate's so we match it's weird changover from Indic to Julian
return QDate::isLeapYear( year );
}