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

Re: RFC: Second attempt at POSIX::strptime() in core

Thread Previous | Thread Next
Paul LeoNerd Evans
September 8, 2011 08:52
Re: RFC: Second attempt at POSIX::strptime() in core
Message ID:
On Fri, Sep 02, 2011 at 11:38:29AM +0100, Nicholas Clark wrote:
> Am I right in thinking that the information strptime() wants to return is
> a) the values of what it parsed
> b) what things it could parse (zero or more from seconds, minutes, hours, etc)
> c) where in the string the parse failed
> ?
> The problems being that strptime() in Time::Piece only tells you (a),
> and has no way of telling you (b) or (c)?

Yes; entirely.

My proposed alternatives of

  my @t = localtime()
  strptime $fmt, $str, \@t


  my @t = strptime $fmt, $str, localtime()

would signal b) by virtue of not altering (in the ARRAYref case), or
returning passthrough (in the function case) the fields that were

The signal for c) is a little more complex - I pondered abusing the
pos() marker on it,$key_=_$tk->parse_key_at_pos(_$str,_$format_)

though I admit I don't yet have a complete specification on this regard.

Paul "LeoNerd" Evans
ICQ# 4135350       |  Registered Linux# 179460

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About