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

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

Thread Next
From:
Paul LeoNerd Evans
Date:
August 30, 2011 07:46
Subject:
RFC: Second attempt at POSIX::strptime() in core
Message ID:
20110830143703.GA18491@cel.leo
So, having quite successfully derailed the previous attempt, lets try
again.

I want

  use POSIX qw( strptime );

to work. I further want it to have actually-useful semantics, which as
demonstrated POSIX::strptime::strptime and Time::Piece::strptime both
lack. Ideally I'd prefer the former of these two semantics, as to most
closely match the POSIX/C API, but given this was such a point of
argument last time, I'd be happy to accept either of these in Perl:

  my @time = localtime;
  strptime $str, $fmt, \@time

  my @time = strptime $str, $fmt, localtime;

Can we have a little consensus these?

-----

Furthermore, I don't think we got to the bottom of how to handle partial
parsing. E.g. I'd like somehow to get the number "10" out of this code:

  strptime "2011-08-30 and here is more of the string", "%Y-%m-%d"

(10 because the space after 30 is the 10th position, so I'd like to
continue parsing from here).

Additionally it'd be lovely if I could parse the following by simply
knowing the number 12 rather than applying a substr operation first:

  strptime substr("The date is 2011-08-30", 12), "%Y-%m-%d"

I posit both can be done with (ab)use of pos().

Opinions?

-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/

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