summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorDamjan Jovanovic <damjan@apache.org>2015-08-26 02:10:46 +0000
committerDamjan Jovanovic <damjan@apache.org>2015-08-26 02:10:46 +0000
commita68493266e9212119f31e58c256f00fb9bcc8d20 (patch)
treeb01b4f340a8f7eb27c086396b5504112049cf95a /basic
parentaec10dffbd66cc6b4a8fc7ca6bb75cf589c81509 (diff)
#i117989# Basic functions Day(), Hour(), Minute(), and Second() return wrong results for dates <1900-1-1
Also extended our spreadsheeet test to search through more columns, open spreadsheets with macros enabled, and added a test for the the Year(), Month(), Day(), Hour(), Minute(), and Second() functions comparing Calc's formulas vs StarBasic's runtime functions. Found-by: villeroy Patch-by: Damjan Jovanovic
Notes
Notes: merged as: 94a52f9ffafdf9c6e64ddf1a3587f21a272f2e62
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods.cxx18
1 files changed, 2 insertions, 16 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 88e1acaa857e..6d5b036ccd97 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1789,17 +1789,9 @@ RTLFUNC(Val)
sal_Int16 implGetDateDay( double aDate )
{
aDate -= 2.0; // normieren: 1.1.1900 => 0.0
+ aDate = floor( aDate );
Date aRefDate( 1, 1, 1900 );
- if ( aDate >= 0.0 )
- {
- aDate = floor( aDate );
- aRefDate += (sal_uIntPtr)aDate;
- }
- else
- {
- aDate = ceil( aDate );
- aRefDate -= (sal_uIntPtr)(-1.0 * aDate);
- }
+ aRefDate += (sal_uIntPtr)aDate;
sal_Int16 nRet = (sal_Int16)( aRefDate.GetDay() );
return nRet;
@@ -2110,8 +2102,6 @@ RTLFUNC(Year)
sal_Int16 implGetHour( double dDate )
{
- if( dDate < 0.0 )
- dDate *= -1.0;
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
@@ -2136,8 +2126,6 @@ RTLFUNC(Hour)
sal_Int16 implGetMinute( double dDate )
{
- if( dDate < 0.0 )
- dDate *= -1.0;
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);
@@ -2177,8 +2165,6 @@ RTLFUNC(Month)
sal_Int16 implGetSecond( double dDate )
{
- if( dDate < 0.0 )
- dDate *= -1.0;
double nFrac = dDate - floor( dDate );
nFrac *= 86400.0;
sal_Int32 nSeconds = (sal_Int32)(nFrac + 0.5);