I would like for time() to return an object, which in numeric context is
the number of seconds from the epoch (the new epoch, of course), and
which in string context is a human-readable string. We could also use
localtime(), and leave time() alone.
Possible syntax could be:
$time_object = time();
$epoch_seconds = +$time_object;
$human_readable = ~$time_object;
$human_readable = $time_object.format; # default format
$human_readable = $time_object.format($pattern);
$human_readable = $time_object.format($pattern, offset => 'local');
The default offset would probably be 'local', and would account for
daylight saving time. The offset could be changed to a
floating-point value indicating hours offset from UTC. A timezone
module could perhaps allow for timezone names, which would allow for
daylight saving time computation for non-local times. The default
offset would probably be stored in a global variable.
The default format would probably be an ISO 8601 format, like:
1994-11-05T08:15:30-05:00
and the default format pattern would probably be stored in a global
variable, possibly as an strftime() pattern.
-kolibrie
What's wrong with porting DateTime?
Rob
Just a friendly note that since this is a language design issue
(as opposed to an implementation one) this thread likely belongs
only on perl6-language and not on perl6-compiler. I'm just trying
to keep the traffic on the lists at a reasonable volume ... :-)
Followups to p6l, please, unless there's an obvious reason why they
need to be on p6c.
Pm