J. David Blackstone wrote:

>  I always treat the return value of time() as a black-box value.  I
>can perform specific actions on it, such as feeding it to localtime()
>or adding relative time intervals to it, such as a year of seconds.
>But I do not allow myself to look at that value.  I was kind of hoping
>Perl6 would formalize this into a black-box value, meaning an object,
>and offload everything into a standard module instead of the core.

thinking about it, I like that idea the best.
for a script to really be cross-platform independent (i.e. a "good" script)
then it can't make assumptions about the internal representation of time.
And if its hidden, then you can change epochs, change operating systems,
and change religions, and your script really wont care.

you'd have three basic things you could do:

1) get calendar time, which would return a year, month, day, hour, minute,
second.
defaulting to the gregorian calendar

2) start stopwatch: which sets a stopwatch to zero, and then you can poll
it
to see how much time has elapsed since you started the stop watch.
default units would be seconds

3)perform some arithemetic on these two things.
     calendar - calendar = elapsed time
     calendar + elapsed time = new calendar time
     etc, etc

both of these could be objects and would enforce the black box.
calendar time would be a static object representing a fixed point in time.
stopwatch would be a dynamic object with a reset and polling method
     to return time elapsed since last reset.

calendar time would have a method that spits out  a string formatted
to the proper, non-ambigous representation,
("16 August, 2000, 11:56 A.M." )
then when 2099 rolls around,  there shouldn't be any Y2.1K problem...

;)

Greg London
always planning ahead....







Reply via email to