summaryrefslogtreecommitdiff
path: root/basic/source/runtime/methods1.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-05-02 15:53:04 +0200
committerEike Rathke <erack@redhat.com>2017-05-02 15:56:20 +0200
commit1b13548f33720d80f53d493f6d70cbcce6b1a0fb (patch)
tree0b797dde491986b97a94b96ed4fb83a6295c1a72 /basic/source/runtime/methods1.cxx
parentd2007136587a8722d0e7045828bca6a6d82fd244 (diff)
BASIC: handle the full tools::Date range from -32768-01-01 to 32767-12-31
* Input of two-digit years only possible through CDateFromIso() though to maintain compatibility with previous behavior and also VBA mode. * VBA mode restricted to years 1..9999 Change-Id: Ia9574c3bf136619b4831b349d263c96b162d1ed4
Diffstat (limited to 'basic/source/runtime/methods1.cxx')
-rw-r--r--basic/source/runtime/methods1.cxx15
1 files changed, 5 insertions, 10 deletions
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index f38d47a882bf..650c0d92fdc9 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -2075,7 +2075,7 @@ RTLFUNC(DateAdd)
sal_Int32 nTargetYear = lNumber + nYear;
nTargetYear16 = limitToINT16( nTargetYear );
nTargetMonth = nMonth;
- bOk = implDateSerial( nTargetYear16, nTargetMonth, nDay, dNewDate );
+ bOk = implDateSerial( nTargetYear16, nTargetMonth, nDay, false, dNewDate );
break;
}
case INTERVAL_Q:
@@ -2119,7 +2119,7 @@ RTLFUNC(DateAdd)
nTargetYear = (sal_Int32)nYear + nYearsAdd;
}
nTargetYear16 = limitToINT16( nTargetYear );
- bOk = implDateSerial( nTargetYear16, nTargetMonth, nDay, dNewDate );
+ bOk = implDateSerial( nTargetYear16, nTargetMonth, nDay, false, dNewDate );
break;
}
default: break;
@@ -2130,16 +2130,11 @@ RTLFUNC(DateAdd)
// Overflow?
sal_Int16 nNewYear, nNewMonth, nNewDay;
implGetDayMonthYear( nNewYear, nNewMonth, nNewDay, dNewDate );
- if( nNewYear > 9999 || nNewYear < 100 )
- {
- StarBASIC::Error( ERRCODE_BASIC_BAD_ARGUMENT );
- return;
- }
sal_Int16 nCorrectionDay = nDay;
while( nNewMonth > nTargetMonth )
{
nCorrectionDay--;
- implDateSerial( nTargetYear16, nTargetMonth, nCorrectionDay, dNewDate );
+ implDateSerial( nTargetYear16, nTargetMonth, nCorrectionDay, false, dNewDate );
implGetDayMonthYear( nNewYear, nNewMonth, nNewDay, dNewDate );
}
dNewDate += dHoursMinutesSeconds;
@@ -2334,7 +2329,7 @@ double implGetDateOfFirstDayInFirstWeek
nFirstWeekMinDays = 7; // vbFirstFourDays
double dBaseDate;
- implDateSerial( nYear, 1, 1, dBaseDate );
+ implDateSerial( nYear, 1, 1, false, dBaseDate );
sal_Int16 nWeekDay0101 = implGetWeekDay( dBaseDate );
sal_Int16 nDayDiff = nWeekDay0101 - nFirstDay;
@@ -2397,7 +2392,7 @@ RTLFUNC(DatePart)
{
sal_Int16 nYear = implGetDateYear( dDate );
double dBaseDate;
- implDateSerial( nYear, 1, 1, dBaseDate );
+ implDateSerial( nYear, 1, 1, false, dBaseDate );
nRet = 1 + sal_Int32( dDate - dBaseDate );
break;
}