advice needed: bug44456 addition of ODF-formula datedif to calc

Winfried Donkers W.Donkers at
Thu Apr 26 04:55:14 PDT 2012


I have added the formula 'datedif', as defined in ODF 1.2 to calc (see diff).

But there are some items I would like to get advise on:
1. parameter fmt in datedif( date1; date2; fmt ) defines the output (d, m, y, yd, ym, md for days, months etc). In my code, the users needs to enter "d" (i.e. use the double quotes around). IMHO, that is not user-friendly. Can anyone tell me how to solve that?
2. the calculation in DateDif(..) uses mean values for days in year (365.2425) and for days in month (30.4369). That will in some instances lead to -seemingly?- incorrect results. Should I do something about that, i.e make the code date-concious?
3. The various defined values for paramter fmt (d, m, y, yd, ym, md) are 'hard' in the code ("d", "m", "y", "yd", "ym", "md"). This does not look neat to me. is there a preferred way of doing such things?
4. Currently, when an undefined value of parameter fmt is passed, the function returns 0 instead of an error message tp the user. Can anyone tell me how to implement a correct and user-friendly handling of incorrect parameter values?
5. ODF 1.2 defines DATEDIF, but the languages I've seen using this function use DATEDIFF. Why is ODF different (or isn't it)?

Thanks for your help!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20120426.diff
Type: application/octet-stream
Size: 14035 bytes
Desc: 20120426.diff
URL: <>

More information about the LibreOffice mailing list