[squeak-dev] Class comment for Date mentions #localizedDates
cunningham.cb at gmail.com
Fri Jul 8 15:26:32 UTC 2016
On Mon, Jun 27, 2016 at 9:40 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> > For what it is worth, I spend >80% of my time working with
> > dates/timestamps, trying to turn them into Magnitudes for manipulations.
> > The other 20%, I really enjoy them as timespans with locales since I deal
> > with times from around the world. But the two uses are not quite easy to
> > deal with - doable, just not quite intuitive.
> > -cbc
> Based on your experience, do you think that it would make sense to have
> two classes for Day and Date, where one represents date as duration, and
> the other represents date as magnitude?
Sorry for the long delay.
Having Date (or Day) as a duration has positive benefits. For instance, I
want to know if a particular timestamp (when something happened, what we
call DateAndTime) happened on a particular Date. The DateAndTime might be
in a different timezone than the Date we are checking. Being able to just
ask 'is this timestamp from this date' is nice:
theDate := ('2016-07-06' asDate start offset: 4 hours) asDate.
theTime := '2016-07-06 20:34:02' asDateAndTime offset: 8 hours.
theDate includes: theTime " => false"
theTime := '2016-07-06 20:34:02' asDateAndTime offset: -8 hours.
theDate includes: theTime " => true"
Although it is hard to get a date in a certain timezone - is there a better
way than what I wrote above? Rarely do I need it in my timezone - instead
I need to specify it directly or not have it present at all.
Most of the time, though, I just as a number, not a duration. I just want
to show it, sometimes work from its beginning to some other time, and
ignore that it is a duration.
Looking at how you are interpreting my statement that I want it as a
magnitude, I think I was using the wrong words. What I really meant was
that I wanted it ignore the duration (and most especially the timezone) -
but not use it as a raw number of some kind.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev