develooper Front page | perl.perl5.porters | Postings from October 2011

Re: RFC: adding POSIX::strptime()

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
October 18, 2011 22:48
Subject:
Re: RFC: adding POSIX::strptime()
Message ID:
20111019054845.GE8720@klangraum.plasmasturm.org
* Paul LeoNerd Evans <leonerd@leonerd.org.uk> [2011-08-04 12:30]:
> On Wed, Aug 03, 2011 at 01:17:19PM +0200, Aristotle Pagaltzis wrote:
> > Heck, the Time::Piece `strptime` can be extended to cover all of the
> > use cases you showed. Beyond setting `pos()` it would just need to
> > allow calling `strptime` as an instance method, and use the values
> > from the constructing object for the default values of unspecified
> > fields.
> >
> > I.e. where you propose
> >
> >     my @time = localtime;
> >     strptime( $str, '%H:%M:%S', \@time );
> >
> > it would instead be
> >
> >     Time::Piece->now->strptime( $str, '%H:%M:%S' );
> >
> > Now isn’t *that* pretty.
>
> LGTM
>
> > The one option this doesn’t give you, compared to the above API, is
> > handling elliptical datetimes.
>
> How do you mean elliptical? If by that you mean the two split partial
> cases, that's still not hard:
>
>    Time::Piece->now
>               ->strptime( "2011/Aug/4", '%Y/%b/%d' )
>               ->strptime( "12:34:56",   '%H:%M:%S' )

I meant that you cannot do the equivalent of passing an undef value into
the proposed POSIX::strptime, because a Time::Piece objects can only
ever represent a complete date, time or datetime.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About