summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-02-20 21:26:20 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-02-20 21:27:38 +0000
commitae838de0a3840e0fd490db5447bd6d481616e9d7 (patch)
tree7bbadb6c1b1506e6c5795c9fcd119ec2bdb380ab /tools
parent2bcd18892f1903d2434bc5dc6828841e49bb78a2 (diff)
fdo#66507 - accelerate date calculations as used vs. empty cells.
Change-Id: I5cd642db4e0595c96e1af8adf7c7a45f589a259e
Diffstat (limited to 'tools')
-rw-r--r--tools/source/datetime/tdate.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/source/datetime/tdate.cxx b/tools/source/datetime/tdate.cxx
index 719219a58afe..720692b7973a 100644
--- a/tools/source/datetime/tdate.cxx
+++ b/tools/source/datetime/tdate.cxx
@@ -33,7 +33,7 @@ struct tm *localtime_r(const time_t *timep, struct tm *buffer);
#endif
static const sal_uInt16 aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,
- 31, 31, 30, 31, 30, 31 };
+ 31, 31, 30, 31, 30, 31 };
#define MAX_DAYS 3636532
@@ -195,7 +195,7 @@ sal_uInt16 Date::GetDayOfYear() const
}
sal_uInt16 Date::GetWeekOfYear( DayOfWeek eStartDay,
- sal_Int16 nMinimumNumberOfDaysInWeek ) const
+ sal_Int16 nMinimumNumberOfDaysInWeek ) const
{
short nWeek;
short n1WDay = (short)Date( 1, 1, GetYear() ).GetDayOfWeek();
@@ -407,6 +407,10 @@ Date& Date::operator +=( long nDays )
sal_uInt16 nDay;
sal_uInt16 nMonth;
sal_uInt16 nYear;
+
+ if (nDays == 0)
+ return *this;
+
long nTempDays = DateToDays( GetDay(), GetMonth(), GetYear() );
nTempDays += nDays;
@@ -428,6 +432,10 @@ Date& Date::operator -=( long nDays )
sal_uInt16 nDay;
sal_uInt16 nMonth;
sal_uInt16 nYear;
+
+ if (nDays == 0)
+ return *this;
+
long nTempDays = DateToDays( GetDay(), GetMonth(), GetYear() );
nTempDays -= nDays;