[Libreoffice] [REVIEW][3-4] date change regression fdo#44385

Eike Rathke erack at redhat.com
Mon Jan 16 08:59:55 PST 2012


Hi Noel,

On Monday, 2012-01-16 16:11:14 +0000, Noel Power wrote:

> >Not every operation on date types should return a date,
> I have to admit I was swayed by Andrew's point that letting the
> operations just return Dates seems more consistent.Also it would
> seem to me subtraction should at least mirror the behaviour of
> addition.
> 
> e.g.
>     something = date() + 1 ' something becomes a variant date ( 1
> day into the future )
>     something = date() - 1 ' something becomes a variant date ( 1
> day in the past ) ( Note: previously this would just be a strange
> double value e.g the numeric rep of the date type )

Yes, these are fine as dates.

> Although I don't really see the point of exponential or division
> etc. operations on dates, keeping the type didn't seem like it would
> cause any problems ( and simplified the code )
> 
> However, given previous bad experiences with basic with seemingly
> minor changes in combination with your query I am getting nervous
> :-/
> >i.e. substracting two dates should return a number of days (I
> >don't think adding/multiplying/dividing two dates makes sense, but
> >it should return a number of days as well).
> hmm  Date 'operation' Date puts a different spin on things :-/
> 
> with the change on master
> 
> dim tomorrow as Date
> dim yesterday as Date
> 
> tomorrow = date() + 1
> yesterday = date() - 1
> result = tomorrow - yesterday ' previously would have given 2 as a
> result with a type variant/double but now gives a strange date (
> result of trying to convert 2 into a date )
> 
> and of course... that's not good :-(
> 
> However I'd still like to see macro code like
> 
>    something = date() - 1
> 
> return a date just like the addition case

Of course.

> We have a number of choices
> 
> a) safest, just restore the old code
> b) not so risky ( I think ), and... would change the present
> behaviour in consistent way for treatment of minus operator
> -                    if( GetType() == SbxDATE || rOp.GetType() == SbxDATE )
> +                    if( ( eOp == SbxPLUS || eOp == SbxMINUS ) && (
> ( GetType() == SbxDATE || rOp.GetType() == SbxDATE ) && ( GetType()
> != rOp.GetType() ) ) )

That one (b) looks good.

> c) risker variant of b that allows all operations on a date type to
> retain it's date type
> 
> -                    if( GetType() == SbxDATE || rOp.GetType() == SbxDATE )
> +                    if( ( GetType() == SbxDATE || rOp.GetType() ==
> SbxDATE ) && ( GetType() != rOp.GetType() ) )

I don't spot sense in 2*today() => 2124-02-02  ;-)

  Eike

-- 
LibreOffice Calc developer. Number formatter stricken i18n transpositionizer.
GnuPG key 0x293C05FD : 997A 4C60 CE41 0149 0DB3  9E96 2F1A D073 293C 05FD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20120116/2c2798a6/attachment.pgp>


More information about the LibreOffice mailing list