[LRUG] Finding the duration between two DateTimes

Eleanor eleanor at goth-chic.org
Wed May 30 09:57:23 PDT 2007


On 29 May 2007, at 13:33, Piers Cawley wrote:
> On 28/05/07, Eleanor <eleanor at goth-chic.org> wrote:
>> Then where you currently create your duration you could write:
>>
>>         duration = Duration.new(Task.duration)
>>
>> However from the perspective of a Task object you may not need any of
>> this complexity. Just because something can be made into an object
>> doesn't necessarily mean that it should...
>
> However, in the case of calendrical calculations, reifying a duration
> makes a great deal of sense. Representing a duration internally as a
> number of seconds makes a great deal less sense though. Consider the
> problems inherent in 1.month, daylight savings, leap years, leap
> seconds and the whole jujuflop situation that is timezones.

It's true that anything to do with calendrical calculations is  
usually a nightmare, but doubly so in project management where  
there's a fair chance that two different calendrical systems will be  
in use: a gregorian calendar with all of its attendant  
inconsistencies, and a standardised man-month calendar. Reconciling  
these can be a real pain. All-told human schemes for marking time are  
amongst the more slippery concepts for computers to deal with. I  
think in Tim's case I'd use minutes as my standard unit if the  
purpose is basic time-management and only adopt a Duration class in  
the event that I wanted to write a feature-complete project  
management tool - but then again, I'm a lazy hacker so HMMV :)


Ellie

Eleanor McHugh
Games With Brains
----
raise ArgumentError unless @reality.responds_to? :reason




More information about the Chat mailing list