sc/source/core/inc/interpre.hxx | 6 +++++- sc/source/core/tool/interpr2.cxx | 9 +++++---- sc/source/core/tool/interpr4.cxx | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-)
New commits: commit 445ae496f9a3b8abf8427e8ffe82d85cdaecd384 Author: Eike Rathke <er...@redhat.com> Date: Wed Nov 30 16:52:56 2011 +0100 sort out Gregorian cut-off date as side effect of validity diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 111f74f..586a4dd 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -551,8 +551,12 @@ void ScTTT(); 1999-03-03. If TRUE, the date passed must be a valid Gregorian calendar date. No two-digit expanding or rollover is done. + + @param bCheckGregorian + If TRUE, date must be Gregorian, i.e. >= 1582-10-15. + If FALSE, don't care, any valid date >= 0-1-1 will do. */ -double GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, bool bStrict ); +double GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, bool bStrict, bool bCheckGregorian ); void ScGetActDate(); void ScGetActTime(); diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index ef42258..5859a1a 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -66,7 +66,8 @@ using namespace formula; // Datum und Zeit //----------------------------------------------------------------------------- -double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, bool bStrict ) +double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int16 nDay, + bool bStrict, bool bCheckGregorian ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetDateSerial" ); if ( nYear < 100 && !bStrict ) @@ -93,7 +94,7 @@ double ScInterpreter::GetDateSerial( sal_Int16 nYear, sal_Int16 nMonth, sal_Int1 Date aDate( nD, nM, nY); if (!bStrict) aDate += nDay - 1; - if (aDate.IsValidAndGregorian()) + if ((!bCheckGregorian && aDate.IsValidDate()) || (bCheckGregorian && aDate.IsValidAndGregorian())) return (double) (aDate - *(pFormatter->GetNullDate())); else { @@ -266,7 +267,7 @@ void ScInterpreter::ScEasterSunday() O = H + L - 7 * M + 114; nDay = sal::static_int_cast<sal_Int16>( O % 31 + 1 ); nMonth = sal::static_int_cast<sal_Int16>( int(O / 31) ); - PushDouble( GetDateSerial( nYear, nMonth, nDay, true ) ); + PushDouble( GetDateSerial( nYear, nMonth, nDay, true, true ) ); } } @@ -283,7 +284,7 @@ void ScInterpreter::ScGetDate() PushIllegalArgument(); else { - PushDouble(GetDateSerial(nYear, nMonth, nDay, false)); + PushDouble(GetDateSerial(nYear, nMonth, nDay, false, true)); } } } diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index d134d74..1bbad1c 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -405,7 +405,7 @@ double ScInterpreter::ConvertStringToValue( const String& rStr ) sal::static_int_cast<sal_Int16>(nUnit[year]), sal::static_int_cast<sal_Int16>(nUnit[month]), sal::static_int_cast<sal_Int16>(nUnit[day]), - true) : 0.0); + true, false) : 0.0); fValue += ((nUnit[hour] * 3600) + (nUnit[minute] * 60) + nUnit[second] + fFraction) / 86400.0; } } _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits