thewebsi has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to work with human-readable date format strings - ie, allow the user to select the date format for input and output using a human-readable string such as 'yyyy-mm-dd'.
Unfortunately, the popular date manipulation strftime()/strptime() functions from POSIX and Time::Piece use a non-human-friendly '%X' format. In my search, I found Time::Format::time_format(), and this does exactly what I want for output (strftime), but there is no input (strptime) equivalent.
Barring any better options, I'll probably write a regex block to convert format strings from a human-readable format to the POSIX format so I can use the standard functions. Before I embark on that however, does anyone have other suggestions? Thanks.
Edit: To clarify, instead of POSIX::strftime ( '%Y %m %d', localtime() ), I'd like to use SomeModule::SomeFunction ( 'yyyy-mm-dd', localtime() ), as Time::Format::time_format() does, but also need support for strptime().
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Human-readable date formats
by Loops (Curate) on Oct 21, 2014 at 02:43 UTC | |
by thewebsi (Scribe) on Oct 21, 2014 at 03:11 UTC | |
by thargas (Deacon) on Oct 21, 2014 at 11:29 UTC | |
by jonadab (Parson) on Oct 22, 2014 at 01:01 UTC | |
|
Re: Human-readable date format strings
by thewebsi (Scribe) on Oct 21, 2014 at 05:28 UTC | |
by Tux (Canon) on Oct 21, 2014 at 06:17 UTC | |
by thewebsi (Scribe) on Oct 21, 2014 at 07:23 UTC | |
by Tux (Canon) on Oct 21, 2014 at 09:43 UTC | |
by choroba (Cardinal) on Oct 21, 2014 at 11:48 UTC | |
|
Re: Human-readable date formats
by Anonymous Monk on Oct 21, 2014 at 02:59 UTC |