Bug 100440

Summary: MONTHS function - third parameter not checked
Product: LibreOffice Reporter: raal <raal>
Component: CalcAssignee: Eike Rathke <erack>
Status: RESOLVED FIXED    
Severity: normal CC: h3734236, miguelangelrv
Priority: medium    
Version: Inherited From OOo   
Hardware: All   
OS: All   
Whiteboard: target:5.3.0
Crash report or crash signature: Regression By:

Description raal 2016-06-16 19:53:20 UTC
https://help.libreoffice.org/Calc/Add-in_Functions#MONTHS
   Type calculates the type of difference. Possible values include 0 (interval) and 1 (in calendar months).

=MONTHS("2010-04-03"; "2011-06-17"; 111) return 14. Should return error.
Comment 1 m_a_riosv 2016-06-16 22:39:59 UTC
Hi @raal,

I think many function have this kind of parameters working in this way, a true/false state, so any value different than zero is true. The same happens with IF() function

I guess so it's quicker to know the parameter state.

I don't think it is a bug.
Comment 2 Eike Rathke 2016-06-30 16:19:40 UTC
> I think many function have this kind of parameters working in this way, a
> true/false state, so any value different than zero is true.

This is not the case for MONTHS(), YEARS() or WEEKS(). Any value other than 1 is evaluated as 0, which at least might be unexpected..
Comment 3 Commit Notification 2016-06-30 16:54:24 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=14e31d6cf4c4ba8a28b932c77994bc905686dba5

Resolves: tdf#100440 check mode to be 0 or 1 for MONTHS(), YEARS() and WEEKS()

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Eike Rathke 2016-06-30 16:55:07 UTC
Note: needed to adapt the WEEKS and YEARS test documents to cope with the change.