line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package DateTime::Format::Atom; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
408299
|
use strict; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
172
|
|
5
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
100
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
3078
|
use version; our $VERSION = qv('v1.0.2'); |
|
3
|
|
|
|
|
13321
|
|
|
3
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
3608
|
use DateTime::Format::RFC3339 qw( ); |
|
3
|
|
|
|
|
519008
|
|
|
3
|
|
|
|
|
85
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
3
|
|
|
3
|
|
28
|
use constant FIRST_IDX => 0; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
184
|
|
13
|
3
|
|
|
3
|
|
19
|
use constant IDX_HELPER => FIRST_IDX + 0; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
236
|
|
14
|
3
|
|
|
3
|
|
17
|
use constant NEXT_IDX => FIRST_IDX + 1; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
765
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
1
|
|
|
1
|
0
|
4
|
my ($class, %opts) = @_; |
19
|
1
|
|
|
|
|
11
|
my $helper = DateTime::Format::RFC3339->new( uc_only => 1 ); |
20
|
1
|
|
|
|
|
14
|
return bless([ |
21
|
|
|
|
|
|
|
$helper, # IDX_HELPER |
22
|
|
|
|
|
|
|
], $class); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub parse_datetime { |
27
|
1
|
|
|
1
|
1
|
20
|
my ($self, $str) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
|
|
9
|
$self = $self->new() |
30
|
|
|
|
|
|
|
if !ref($self); |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
10
|
return $self->[IDX_HELPER]->parse_datetime($str); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub format_datetime { |
37
|
1
|
|
|
1
|
1
|
118
|
my ($self, $dt) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# $self = $self->new() |
40
|
|
|
|
|
|
|
# if !ref($self); |
41
|
|
|
|
|
|
|
# |
42
|
|
|
|
|
|
|
# return $self->[IDX_HELPER]->format_datetime($dt); |
43
|
1
|
|
|
|
|
9
|
return DateTime::Format::RFC3339->format_datetime($dt); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 NAME |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
DateTime::Format::Atom - Parse and format Atom datetime strings |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 VERSION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Version 1.0.2 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
use DateTime::Format::Atom; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
my $f = DateTime::Format::Atom->new(); |
67
|
|
|
|
|
|
|
my $dt = $f->parse_datetime( '2002-07-01T13:50:05Z' ); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# 2002-07-01T13:50:05Z |
70
|
|
|
|
|
|
|
print $f->format_datetime($dt); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 DESCRIPTION |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This module understands the Atom date/time format, an ISO 8601 profile, defined |
76
|
|
|
|
|
|
|
at L<http://tools.ietf.org/html/rfc4287> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
It can be used to parse these formats in order to create the appropriate |
79
|
|
|
|
|
|
|
objects. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
All the work is actually done by L<DateTime::Format::RFC3339>. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 METHODS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=over |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item C<parse_datetime($string)> |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Given a Atom datetime string, this method will return a new |
90
|
|
|
|
|
|
|
L<DateTime> object. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
If given an improperly formatted string, this method will croak. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
For a more flexible parser, see L<DateTime::Format::ISO8601>. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item C<format_datetime($datetime)> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Given a L<DateTime> object, this methods returns a Atom datetime |
99
|
|
|
|
|
|
|
string. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
For simplicity, the datetime will be converted to UTC first. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=back |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=over 4 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * L<DateTime> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * L<DateTime::Format::RFC3339> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * L<DateTime::Format::ISO8601> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * L<http://tools.ietf.org/html/rfc3339>, "Date and Time on the Internet: Timestamps" |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * L<http://tools.ietf.org/html/rfc4287>, "The Atom Syndication Format" |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 BUGS |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-datetime-format-atom at rt.cpan.org>, |
127
|
|
|
|
|
|
|
or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DateTime-Format-Atom>. |
128
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SUPPORT |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
perldoc DateTime::Format::Atom |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
You can also look for information at: |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * Search CPAN |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/DateTime-Format-Atom> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=DateTime-Format-Atom> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L<http://annocpan.org/dist/DateTime-Format-Atom> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * CPAN Ratings |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/DateTime-Format-Atom> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 AUTHOR |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Eric Brine, C<< <ikegami@adaelis.com> >> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
No rights reserved. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
The author has dedicated the work to the Commons by waiving all of his |
170
|
|
|
|
|
|
|
or her rights to the work worldwide under copyright law and all related or |
171
|
|
|
|
|
|
|
neighboring legal rights he or she had in the work, to the extent allowable by |
172
|
|
|
|
|
|
|
law. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Works under CC0 do not require attribution. When citing the work, you should |
175
|
|
|
|
|
|
|
not imply endorsement by the author. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |