On Mon, Apr 9, 2018 at 1:46 PM, Sean P. DeNigris <[email protected]>
wrote:
> Sven Van Caekenberghe-2 wrote
> > So you want to change '1/1/1990' asDate so that it does the equivalent of
> > (DateAndTime fromString: '1990-01-01T00:00:00Z') asDate.
>
> Precisely.
>
> That won't work :)
'1/1/1990' asDate =
(DateAndTime fromString: '1990-01-01T00:00:00Z') asDate -> true
(DateAndTime fromString: '1990-01-01T00:00:00Z') asDate start ->
1990-01-01T00:00:00-04:00
The date doesn't change converted to local timezone. So you could solve
your problem by comparing just the date part yyyymmdd.
Note that
Timespan >> = comparand
^ self class = comparand class
and: [ self start = comparand start
and: [ self duration = comparand duration ] ]
Maybe a good solution is to modify the start check for the Date class? I
don't seem to have any real control over the start so having that be part
of my check and fail seems wrong on this class.
Date >> starting: aDateAndTime
^super starting: (aDateAndTime midnight) duration: (Duration days: 1)
Suggest the fix is
Date>> = comparand
^ self class = comparand class
and: [ "Converts to current tz for comparision"
self start midnight = comparand start midnight
and: [ self duration = comparand duration ] ]
or
Date>> = comparand
^ self class = comparand class
and: [ "Compare only date part"
self start yyyymmdd = comparand start yyyymmdd
and: [ self duration = comparand duration ] ]
Seems to match the intent of the class without changing the timezone.
All the best,
Ron Teitelbaum
> Sven Van Caekenberghe-2 wrote
> > While you would not want to change Date today so that it does the
> > equivalent of DateAndTime now asUTC asDate.
>
> I guess it would make sense for consistency and thinking further,
> `yesterday` and friends suffer from the same problems we've been
> discussing.
>
>
>
> -----
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html
>
>
>