| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: /mirror/perl/DateTime-Format-RSS/trunk/lib/DateTime/Format/RSS.pm 63379 2008-06-17T20:51:20.618065Z daisuke $ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Copyright (c) 2006 Daisuke Maki |
|
4
|
|
|
|
|
|
|
# All rights reserved. |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package DateTime::Format::RSS; |
|
7
|
3
|
|
|
3
|
|
17
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
118
|
|
|
8
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
105
|
|
|
9
|
3
|
|
|
3
|
|
14
|
use vars qw($VERSION); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
176
|
|
|
10
|
3
|
|
|
3
|
|
1720
|
use DateTime::Format::Mail; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use DateTime::Format::ISO8601; |
|
12
|
|
|
|
|
|
|
use DateTime::Format::DateParse; |
|
13
|
|
|
|
|
|
|
use base qw(Class::Accessor::Fast); |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors($_) for qw(parsers version); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
BEGIN |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
|
|
|
|
|
|
$VERSION = '0.03000'; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
|
|
|
|
|
|
my $class = shift; |
|
25
|
|
|
|
|
|
|
my %args = @_; |
|
26
|
|
|
|
|
|
|
my $self = $class->SUPER::new({ |
|
27
|
|
|
|
|
|
|
version => $args{version} || '1.0', |
|
28
|
|
|
|
|
|
|
parsers => [ |
|
29
|
|
|
|
|
|
|
# order matters |
|
30
|
|
|
|
|
|
|
DateTime::Format::Mail->new, |
|
31
|
|
|
|
|
|
|
DateTime::Format::ISO8601->new, |
|
32
|
|
|
|
|
|
|
'DateTime::Format::DateParse', |
|
33
|
|
|
|
|
|
|
] |
|
34
|
|
|
|
|
|
|
}); |
|
35
|
|
|
|
|
|
|
return $self; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub parse_datetime |
|
39
|
|
|
|
|
|
|
{ |
|
40
|
|
|
|
|
|
|
my $self = shift; |
|
41
|
|
|
|
|
|
|
my $date = shift; |
|
42
|
|
|
|
|
|
|
if (! ref($self)) { |
|
43
|
|
|
|
|
|
|
$self = $self->new(); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $dt; |
|
47
|
|
|
|
|
|
|
foreach my $p (@{$self->parsers}) { |
|
48
|
|
|
|
|
|
|
$dt = eval { $p->parse_datetime($date) }; |
|
49
|
|
|
|
|
|
|
last if $dt; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
return $dt; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub format_datetime |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
|
|
|
|
|
|
my $self = shift; |
|
57
|
|
|
|
|
|
|
if ($self->version eq '2.0') { |
|
58
|
|
|
|
|
|
|
return $self->parsers->[0]->format_datetime($_[0]); |
|
59
|
|
|
|
|
|
|
} else { |
|
60
|
|
|
|
|
|
|
return $_[0]->iso8601; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |