Issue 117989 - Basic functions Day(), Hour(), Minute(), and Second() return wrong results for dates <1900-1-1
Summary: Basic functions Day(), Hour(), Minute(), and Second() return wrong results fo...
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: scripting (show other issues)
Version: 3.4.0 Beta (OOo)
Hardware: All All
: P3 Normal (vote)
Target Milestone: 4.1.2
Assignee: ab
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-06 19:08 UTC by villeroy
Modified: 2015-10-18 01:13 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.1.1
Developer Difficulty: ---
pescetti: 4.1.2_release_blocker+


Attachments
Spreadsheet comparing numeric ISO-Dates with Basic Hour, Day, Month etc. (18.24 KB, application/vnd.oasis.opendocument.spreadsheet)
2011-05-06 19:16 UTC, villeroy
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description villeroy 2011-05-06 19:08:49 UTC
The issue can be demonstrated with userdefined spreadsheet functions. See attached Calc sheet.
Comment 1 villeroy 2011-05-06 19:16:02 UTC
Created attachment 76491 [details]
Spreadsheet comparing numeric ISO-Dates with Basic Hour, Day, Month etc.

Same issue with OOo3.4beta, LO3.3 and OOo2.4.3
Comment 2 Oliver-Rainer Wittmann 2012-06-13 12:19:14 UTC
getting rid of value "enhancement" for field "severity".
For enhancement the field "issue type" shall be used.
Comment 3 damjan 2012-10-31 03:48:28 UTC
Hour, Day and Month work fine, but CDate is wrong.

According to the documentation for CDate, "In numeric expressions, values to the left of the decimal represent the date, beginning from December 31, 1899". So this is apparently designed that way.
Comment 4 damjan 2015-08-26 02:06:13 UTC
Actually CDate() works, the real problem is that Day(), Hour(), Minute() and Second() are returning wrong values due to arithmetic errors, rounding wrongly, and floor()/ceil() issues.
Comment 5 SVN Robot 2015-08-26 02:10:47 UTC
"damjan" committed SVN revision 1697807 into trunk:
#i117989# Basic functions Day(), Hour(), Minute(), and Second() return wrong ...
Comment 6 damjan 2015-08-26 02:13:08 UTC
Patch and tests committed, resolving fixed.
Comment 7 Kay 2015-09-04 22:24:50 UTC
Verified fixed. Recommend as release blocker due to age of issue.
Comment 8 Andrea Pescetti 2015-09-10 12:13:15 UTC
In principle this looks OK to me as a 4.1.2 blocker. Just one question: how realistic is it that someone wrote code that relies on OpenOffice returning the "wrong" values? At first sight I would say that this is quite unrealistic and that there would be no justification whatsoever for it.

In other words: I do not see much as a change in the Basic specifications but rather as a simple bugfix.

If you share this vision, Damjan feel free to commit your patch to AOO410 too. See https://bz.apache.org/ooo/show_bug.cgi?id=126281#c11 for details (or, of course, I can do it too, just ask).
Comment 9 SVN Robot 2015-09-25 23:27:01 UTC
"pescetti" committed SVN revision 1705378 into branches/AOO410:
#i117989# Basic functions Day(), Hour(), Minute(), and Second() return wrong ...
Comment 10 Andrea Pescetti 2015-10-06 22:58:38 UTC
Already committed both to trunk and AOO410 for OpenOffice 4.1.2.
Comment 11 Andrea Pescetti 2015-10-17 22:13:48 UTC
To verify: download RC2 from https://dist.apache.org/repos/dist/dev/openoffice/4.1.2-rc2-r1707648/binaries/en-US/ and open villeroy's nice test document ("Spreadsheet comparing...") form the Attachments section in this issue page.
Comment 12 Pedro 2015-10-18 01:13:00 UTC
Verified fixed with

AOO412m2(Build:9781)  -  Rev. 1707648
2015-09-28 12:45:04 (Mo, 28 Sep 2015)

under Windows 7 Pro x64 SP1