almut has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to parse and reformat date strings which look like this on input:
11 Mär 08 22:54 CET
The formats may vary slightly, but they all have in common that months are in German. Date::Manip generally does support parsing dates in several languages, and although this generally works fine, there seems to be a problem with the month "Mär" (March).
Here's some demo code:
use Date::Manip; Date_Init("Language=German", "DateFormat=non-US", "TZ=UTC"); for my $date_in ( "11 Jan 08 22:54 CET", "11 Mär 08 22:54 CET", "11 Mai 08 22:54 CEST", "11 Okt 08 22:54 CEST", "11 Dez 08 22:54 CET", ) { my $date_out = UnixDate( ParseDate($date_in), "%Y-%m-%d_%H:%M:%S" +); printf "%-20s --> %s\n", $date_in, $date_out; }
The output:
11 Jan 08 22:54 CET --> 2008-01-11_21:54:00 11 Mär 08 22:54 CET --> 11 Mai 08 22:54 CEST --> 2008-05-11_20:54:00 11 Okt 08 22:54 CEST --> 2008-10-11_20:54:00 11 Dez 08 22:54 CET --> 2008-12-11_21:54:00
The expected output for 11 Mär 08 22:54 CET would be 2008-03-11_21:54:00
Suspecting some encoding issue, I also tried to supply the input as Unicode (UTF-8) instead of ISO Latin-1. Same result. (Taking a look at the source suggests the module isn't using Unicode. But just in case.)
So what am I doing wrong?
(I'm using Date:Manip v5.54, as currently available from CPAN.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Date::Manip and German months names
by moritz (Cardinal) on Jul 09, 2008 at 20:16 UTC | |
by ikegami (Patriarch) on Jul 09, 2008 at 22:12 UTC | |
by EvanCarroll (Chaplain) on Jul 10, 2008 at 09:10 UTC | |
by ikegami (Patriarch) on Jul 10, 2008 at 09:14 UTC | |
|
Re: Date::Manip and German months names
by jethro (Monsignor) on Jul 09, 2008 at 19:59 UTC | |
by almut (Canon) on Jul 09, 2008 at 20:27 UTC | |
by ikegami (Patriarch) on Jul 09, 2008 at 22:20 UTC | |
by almut (Canon) on Jul 09, 2008 at 23:22 UTC | |
by ikegami (Patriarch) on Jul 10, 2008 at 00:15 UTC | |
| |
|
Re: Date::Manip and German months names
by EvanCarroll (Chaplain) on Jul 09, 2008 at 19:12 UTC | |
by almut (Canon) on Jul 09, 2008 at 19:33 UTC | |
by EvanCarroll (Chaplain) on Jul 09, 2008 at 19:37 UTC | |
by ikegami (Patriarch) on Jul 09, 2008 at 19:45 UTC | |
| |
by ikegami (Patriarch) on Jul 09, 2008 at 19:30 UTC | |
|
Re: Date::Manip and German months names
by EvanCarroll (Chaplain) on Jul 10, 2008 at 19:05 UTC |