Front page | perl.perl6.language |
Postings from May 2005
date and time formatting
Thread Next
From:
Nathan Gray
Date:
May 31, 2005 06:44
Subject:
date and time formatting
Message ID:
20050531132311.GA16204@vs2.capwiz.com
As I am interested in human-readable dates and times, and having found
no conclusive discussion on time formatting, I make my recommendation
for a syntax (to start discussion, and allow for date formatting to be
implemented in pugs):
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
Thread Next
-
date and time formatting
by Nathan Gray