Kirk Haines wrote:
> On Tuesday 15 November 2005 6:52 am, Daniel Schierbeck wrote:
> 
>>> I *wish* Time and DateTime worked more like Fixnum and Bignum.
>>>
>>> Chris
>> What kind of change would you suggest?
> 
> The analagous behavior would be for every Time method that could have a date 
> out of range check its inputs, and if that is going to occur, it switched 
> over to DateTime.  However, within the library, that poses some issues.
> 
> First, it means lots of value checks on many methods, which is additional 
> overhead.  It also means that in order for this to be relatively transparent, 
> implementations of a plethora of Time methods, like gm and local and others, 
> for DateTime.  Then, though, does one take the mountain of methods unique to 
> Date/DateTime and make versions of them in Time?  It seems like an awful lot 
> of code and overhead added to the system libraries for something that's 
> pretty easy to detect and handle oneself in cases where it is needed, IMHO.
> 
> The internal and external aspects of the two classes are so different that I 
> think it's dangerous to have any built-in casting from one to the other in 
> the standard library.
> 
> I think that there should be some convenience methods, as we have discussed, 
> to go to and from the three classes (Date, DateTime, and Time), though.  One 
> should not have to reinvent that wheel.
> 
> 
> Kirk Haines
> 
> 
I agree. Though I think the very it's odd that Time and DateTime 
essentially do the same thing (they both represent a date and a time).

This hierarchy would be clearer to me

Time        - e.g. 13:05:23 or 5:43 PM
Date        - e.g. June 5 1978 A.C. or August 2 430 B.C.
   DateTime  - e.g. 5:43 PM, June 5 1978 A.C.

This would basically make a Time instance represent a time of day, and 
not also a date.

   dt = DateTime.now
   dt.date  # returns a Date object
   dt.time  # returns a Time object

There could also be a TimeDuration, which represent, well, a duration of 
time, e.g. 134 hours, 34 minutes and 11 seconds.


just my $ 5 * 10^-2
Daniel