diff options
author | gueux <gueux@gueux.org> | 2010-04-05 16:42:24 +0000 |
---|---|---|
committer | gueux <gueux@gueux.org> | 2010-04-05 16:42:24 +0000 |
commit | c1afaa6973652a99b0d427eb7fe4becb5c7a55f8 (patch) | |
tree | 15ca303cae656a46f54883697feb2ef1145eebc5 | |
parent | 7f71cf3453c72711a052ec66bfb8b1ea0d410d44 (diff) |
DateTime-Format-ISO8601-ParseDateTag
-rw-r--r-- | DateTime/Format/ISO8601/ParseDateTag.pm | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/DateTime/Format/ISO8601/ParseDateTag.pm b/DateTime/Format/ISO8601/ParseDateTag.pm deleted file mode 100644 index 383374a..0000000 --- a/DateTime/Format/ISO8601/ParseDateTag.pm +++ /dev/null @@ -1,99 +0,0 @@ -package DateTime::Format::ISO8601::ParseDateTag; - -use strict; - -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); - -$VERSION = '0.02'; - -use warnings; -use DateTime::Format::ISO8601; - - -my $iso8601 = DateTime::Format::ISO8601->new; -#my $iso8601 = DateTime::Format::ISO8601->new(base_datetime=> $datedefault); -#my $iso8601 = DateTime::Format::ISO8601->set_base_datetime( object => $datedefault ); - -sub new { - my($class, %args) = @_; - my $self = bless({}, $class); - return $self; -} - - -sub pretty_print_date { - my $tmp = ""; - # date if the month is specified - if ( $_[0] >= 2 ) { - $tmp = $tmp . $_[1]->month_abbr . " "; - # date if the day is specified - if ( $_[0] >= 3 ) { - $tmp = $tmp . $_[1]->day . " " . $_[1]->year; - # date if the hour is specified - if ( $_[0] >= 4 ) { - $tmp = $tmp . " at " . $_[1]->hour; - # date if the minute is specified - if ( $_[0] >= 5 ) { - $tmp = $tmp . ":" . $_[1]->minute; - if ( $_[0] >= 6 ) { - # date if the second is specified - $tmp = $tmp . ":" . $_[1]->second; - if ( $_[0] >= 7 ) { - # date if the nanosecond is specified - $tmp = $tmp . ":" . $_[1]->nanosecond; - } - } - } - } - } - # date if the day is not specified - else { - $tmp = $tmp . $_[1]->year; - } - } - # date if the month is not specified - else { - $tmp = $tmp . $_[1]->year; - } - return $tmp; -} - -sub parse { - my $self = shift; - - if ( $_[0] =~ /^(([0-9]|-|T|:)+)(?:\/(([0-9]|-|T|:)*))(?:\s*(.*))$/i ) { - my $date1 = $1; - my $date2 = $3; - my $ed = $5; - my $count1 = () = $date1 =~ /\d+/g; - my $tmp1 = pretty_print_date($count1,$iso8601->parse_datetime($date1)); - substr($date1,-length($date2),length($date2),$date2); - my $tmp2 = pretty_print_date($count1,$iso8601->parse_datetime($date1)); - if ( $ed !~ /^$/i ) { - $ed = ucfirst($ed); - return "$ed between $tmp1 and $tmp2"; - } - else { - return "Released between $tmp1 and $tmp2"; - }; - } - elsif ( $_[0] =~ /^(([0-9]|-|T|:)+)(?:\s*(.*))$/i ) { - my $date = $1; - my $ed = $3; - my $count = () = $date =~ /\d+/g; - my $tmp = ""; - # "on" or "in"? - if ( $count >= 3 ) { $tmp = "on " . $tmp; } else { $tmp = "in " . $tmp; }; - $tmp = $tmp . pretty_print_date($count,$iso8601->parse_datetime($date)); - if ( $ed !~ /^$/i ) { - $ed = ucfirst($ed); - return "$ed $tmp"; - } - else { - return "Released $tmp"; - }; - }; -} - -1; -__END__ |