https://bugs.documentfoundation.org/show_bug.cgi?id=144678

            Bug ID: 144678
           Summary: Functions MONTHS and YEARS give wrong results for
                    pre-1582-10-15 dates when used with last argument set
                    to 1
           Product: LibreOffice
           Version: 3.4.0 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: Calc
          Assignee: [email protected]
          Reporter: [email protected]

Consider the following spreadsheet formulas:

=MONTHS("1599-12-22";"1599-12-23";1)
=MONTHS("1599-12-31";"1600-01-01";1)
=YEARS("1599-12-22";"1599-12-23";1)
=YEARS("1599-12-31";"1600-01-01";1)

They return 0, 1, 0, and 1, respectively, as one would expect.

Now consider these:

=MONTHS("1499-12-22";"1499-12-23";1)
=MONTHS("1499-12-31";"1500-01-01";1)
=YEARS("1499-12-22";"1499-12-23";1)
=YEARS("1499-12-31";"1500-01-01";1)

They return 1, 0, 1, 0, respectively - which is completely unexpected.
The problem is, that the former set of formulas is after 1582-10-15, which is
when Gregorian calendar was introduced, and the latter set is before that date;
the dates sent to the functions in the latter set get converted to serial dates
as Julian dates, but MONTHS and YEARS use proleptic Gregorian to determine the
result when calculating with calendar months/years.

In OOo 3.2 and LO 3.3.0.4, the latter set resulted in #VALUE!; while LO 3.4.0.1
already produces the values described above. Not a regression though, rather
implementation error?

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to