Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On 21/01/12 01:42, Andrew Douglas Pitonyak wrote:
I believe that you intend to cause the following behavior:

date + num        Date
date - num         Date
date * num         Double
date / num          Double
date + date        Date [2]
date - date         Double [3]
date * date         Double

[2] - I prefer this, but I would not spend much energy advocating it.
[3] - I would have subtraction return the same type as addition. So, if "date + date" returns "date", then I would return date for [3]. If you have [2] return a double, then have [3] return a double.

My opinion is that you now just pick one and do it. I will call it a consensus and back your decision in the unlikely event I am ever called upon to do so.

so, in general terms I can accept that subtraction will result in either a Date or a Double ( depending on whether one or both sides of the operation are Dates ). I can also accept that adding a number to a Date should result in a Date also makes sense. I have more difficulty understanding why adding 2 dates should give a Date as a result and am (like you) a little uncomfortable about the lack of symmetry regarding treatment of '-/+'. However, having an overriding rule that ensures any '+' operation involving a Date type results in a Date type does ensure that those operations you mentioned previously e.g. something like
    Date1 + num + Date2
will result in a Date type maybe explains the reason for this lack of symmetry in the treatment of '+/-'. Anyway since I can't make anymore sense of this I prefer to defer to both the previous behaviour ( and additionally behavriour of mso vba ) and modify the behaviour in the minimum way, e.g. just change the behaviour of Date - 'num' to return a Date. So, I will commit a change to provide the behaviour as is described in the table above ( including the asymmetric treatment of +/- ). That's not to say we couldn't or shouldn't change the behaviour of '+' later, just right now I am not comfortable with doing that.

Noel

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.