Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

date and time formatting

1 view
Skip to first unread message

Nathan Gray

unread,
May 31, 2005, 9:23:11 AM5/31/05
to perl6-l...@perl.org, perl6-c...@perl.org
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

Rob Kinyon

unread,
May 31, 2005, 9:51:33 AM5/31/05
to Nathan Gray, perl6-l...@perl.org, perl6-c...@perl.org
On 5/31/05, Nathan Gray <koli...@graystudios.org> wrote:
> 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):

What's wrong with porting DateTime?

Rob

Patrick R. Michaud

unread,
May 31, 2005, 11:09:34 AM5/31/05
to Nathan Gray, perl6-l...@perl.org, perl6-c...@perl.org
On Tue, May 31, 2005 at 09:23:11AM -0400, Nathan Gray wrote:
> 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.

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

0 new messages