Questions On Proposed ANSI Standard DateAndTime

R. A. Harmon harmonra at webname.com
Sat Jul 4 15:50:35 UTC 1998


Hi Squeakers:

I'm trying to implement the <DateAndTime> protocol messages, but can't get a
feel for what their definitions mean in terms concrete enough to implement.
I posted a question about this on the comp.lang.smalltalk news group, but
didn't get a response.  I hope someone in the Squeak community might be able
to help.  I think I could figure out how <DateAndTime> works if I could just
see what the various messages do with examples of real dates and times.  Any
help would be greatly appreciated.

I'll use a short-hand notation of the class name with example values in parens.
        Duration(d:hh:mm:ss)
        DateAndTime(yy/mm/dd, hh:mm:ss, d:hh:mm:ss)
                      date      time      offset


As I understand it, a date and time in UTC means the date and time in GMT.
So a DateAndTime class>>#year:month:day:hour:minute:second: message
given the values for 8:00 am in California on April 26, 1997 return an instance
DateAndTime(97/04/26, 02:00:00, 0:06:00:00).

        
What does DateAndTime return from the following:

        DateAndTime(97/04/26, 02:00:00, 0:06:00:00) + Duration(0:00:00:11)
        ???-> DateAndTime(97/04/26, 02:00:11, 0:06:00:00)

        DateAndTime(97/04/26, 02:00:00, 0:06:00:00) + Duration(-0:00:00:11)
        ???-> DateAndTime(97/04/26, 01:59:49, 0:06:00:00)


I think the implementation of DateAndTime>>#< should be as follows:

< operand
    self offset = operand offset ifTrue: [
        self theDate < operand theDate ifFalse: [
            ^true       "receiver #year, #month, & #day
                        < operand #year, #month, & #day."
        ].
        (self theDate = operand theDate)
        & (self theTime < operand theTime)
        ifTrue: [
            ^true       "receiver #hour24, #minute, #second
                        < operand #hour24, #minute, #second."
        ].
        ^false
    ].
    ^self asUTC < operand asUTC


Is the following result correct in that any of the operands are
negative, it reduces the duration as the -1 in the second example
reduces the one minute duration to 59 seconds?

        Duration days: 0 hours: 0  minutes: 1 seconds: 1
        ???-> Duration(0:00:01:01)

        Duration days: 0 hours: 0 minutes: 1 seconds: -1
        ???-> Duration(0:00:00:59)


Is the following result of the Duration>>#* message correct?

        (Duration days: 1 hours: 0 minutes: 0 seconds: 1) * 9
        ???-> Duration(9:00:00:09)


Is the following result of the Duration>>#asLocal message correct?

        DateAndTime(97/04/26, 02:00:00, 0:06:00:00) asLocal
        ???-> DateAndTime(97/04/26, 08:00:00, 0:00:00:00)


Is the following result of the Duration>>#asUTC message correct?

        DateAndTime(97/04/26, 02:00:00, 0:06:00:00) asUTC
        ???-> DateAndTime(97/04/26, 02:00:00, 0:06:00:00)

        DateAndTime(97/04/26, 08:00:00, 0:00:00:00) asUTC
        ???-> DateAndTime(97/04/26, 02:00:00, 0:06:00:00)


Should the Duration>>#< message given an operand other than an instance of
class Duration generate an error or return false?


Is the correct global name DateAndTime or DateTime?


I haven't this much trouble understanding a concept since trying to
understand "present value of future dollars".  Or was it "future value of
present dollars"?  Or maybe it was "dollar value of future presents"?

--
Richard A. Harmon          "The only good zombie is a dead zombie"
harmonra at webname.com           E. G. McCarthy





More information about the Squeak-dev mailing list