1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use Date::Format; use Date::Language; use Date::Parse; my $lang_date = Date::Language->new('German'); while (my $date_string = <DATA>) { chomp($date_string); next if not length $date_string; print "$date_string ist Unixtime ", $lang_date->str2time($date_string), " und ", $lang_date->time2str( '%d.%m.%Y %T (%Z)',$lang_date->str2time($date_string) ), "\n"; } =for output ergibt: 1.3.1999 ist Unixtime 915318000 und 03.01.1999 00:00:00 (CET) 1 März 1999 ist Unixtime 920242800 und 01.03.1999 00:00:00 (CET) 1. März 1999 ist Unixtime 920242800 und 01.03.1999 00:00:00 (CET) 1/3/1999 ist Unixtime 915318000 und 03.01.1999 00:00:00 (CET) =cut __DATA__ 1.3.1999 1 März 1999 1. März 1999 1/3/1999
QuoteBUGS
When both the month and the date are specified in the date as numbers they are always parsed assuming that the month number comes before the date. This is the usual format used in American dates.
The reason why it is like this and not dynamic is that it must be deterministic. Several people have suggested using the current locale, but this will not work as the date being parsed may not be in the format of the current locale.
My plans to address this, which will be in a future release, is to allow the programmer to state what order they want these values parsed in.
2012-01-12T19:40:59 GwenDragonAxo. Muss ich halt versuchen zu erkennen, welche Sprache jemand verwendet und dann die Dateumszeichenkette im Programm ändern.
Quote23. 3. 1999
QuoteDay '1999' out of range 1..31