File Coverage

blib/lib/DateTime/Format/Atom.pm
Criterion Covered Total %
statement 21 24 87.5
branch n/a
condition n/a
subroutine 7 8 87.5
pod 3 3 100.0
total 31 35 88.5


line stmt bran cond sub pod time code
1              
2             package DateTime::Format::Atom;
3              
4 3     3   1499222 use strict;
  3         10  
  3         159  
5 3     3   27 use warnings;
  3         6  
  3         214  
6              
7 3     3   560 use version; our $VERSION = qv( 'v1.8.0' );
  3         2548  
  3         25  
8              
9 3     3   2126 use DateTime::Format::RFC3339 qw( );
  3         714103  
  3         87  
10              
11              
12 3     3   21 use constant NEXT_IDX => 0;
  3         5  
  3         495  
13              
14              
15             my $helper = DateTime::Format::RFC3339->new( uc_only => 1 );
16              
17              
18             sub new {
19 0     0 1 0 my $class = shift;
20             #my %opts = @_;
21              
22 0         0 my $self = bless( [], $class );
23              
24             # $self->[ IDX_HELPER ]->parse_datetime( $str );
25              
26 0         0 return $self;
27             }
28              
29              
30             sub parse_datetime {
31 1     1 1 183404 my $self = shift;
32 1         3 my $str = shift;
33              
34             # $self = $default_self //= $self->new()
35             # if !ref( $self );
36             #
37             # return $self->[ IDX_HELPER ]->parse_datetime( $str );
38              
39 1         6 return $helper->parse_datetime( $str );
40             }
41              
42              
43             sub format_datetime {
44 1     1 1 294132 my $self = shift;
45 1         2 my $dt = shift;
46              
47             # $self = $default_self //= $self->new()
48             # if !ref( $self );
49             #
50             # return $self->[ IDX_HELPER ]->format_datetime( $dt );
51              
52 1         8 return $helper->format_datetime( $dt );
53             }
54              
55              
56             1;
57              
58              
59             __END__
60              
61             =head1 NAME
62              
63             DateTime::Format::Atom - Parse and format Atom datetime strings
64              
65              
66             =head1 VERSION
67              
68             Version 1.8.0
69              
70              
71             =head1 SYNOPSIS
72              
73             use DateTime::Format::Atom;
74              
75             my $format = DateTime::Format::Atom->new();
76             my $dt = $format->parse_datetime( '2002-07-01T13:50:05Z' );
77              
78             # 2002-07-01T13:50:05Z
79             print $format->format_datetime( $dt );
80              
81              
82             =head1 DESCRIPTION
83              
84             This module understands the Atom date/time format, an ISO 8601 profile, defined
85             at L<http://tools.ietf.org/html/rfc4287>
86              
87             It can be used to parse these formats in order to create the appropriate
88             objects.
89              
90             All the work is actually done by L<DateTime::Format::RFC3339>.
91              
92             =head1 CONSTRUCTOR
93              
94             =head2 new
95              
96             my $format = DateTime::Format::Atom->new();
97              
98              
99             =head1 METHODS
100              
101             =head2 parse_datetime
102              
103             my $dt = DateTime::Format::Atom->parse_datetime( $string );
104             my $dt = $format->parse_datetime( $string );
105              
106             Given a Atom datetime string, this method will return a new
107             L<DateTime> object.
108              
109             If given an improperly formatted string, this method will croak.
110              
111             For a more flexible parser, see L<DateTime::Format::ISO8601>.
112              
113              
114             =head2 format_datetime
115              
116             my $string = DateTime::Format::Atom->format_datetime( $dt );
117             my $string = $format->format_datetime( $dt );
118              
119             Given a L<DateTime> object, this methods returns a Atom datetime
120             string.
121              
122              
123             =head1 SEE ALSO
124              
125             =over 4
126              
127             =item * L<DateTime>
128              
129             =item * L<DateTime::Format::RFC3339>
130              
131             =item * L<DateTime::Format::ISO8601>
132              
133             =item * L<http://tools.ietf.org/html/rfc3339>, "Date and Time on the Internet: Timestamps"
134              
135             =item * L<http://tools.ietf.org/html/rfc4287>, "The Atom Syndication Format"
136              
137             =back
138              
139              
140             =head1 DOCUMENTATION AND SUPPORT
141              
142             You can find documentation for this module with the perldoc command.
143              
144             perldoc DateTime::Format::Atom
145              
146             You can also find it online at this location:
147              
148             =over
149              
150             =item * L<https://metacpan.org/dist/Datetime-Format-Atom>
151              
152             =back
153              
154             If you need help, the following are great resources:
155              
156             =over
157              
158             =item * L<https://stackoverflow.com/|StackOverflow>
159              
160             =item * L<http://www.perlmonks.org/|PerlMonks>
161              
162             =item * You may also contact the author directly.
163              
164             =back
165              
166              
167             =head1 BUGS
168              
169             Please report any bugs or feature requests using L<https://github.com/ikegami/perl-Datetime-Format-Atom/issues>.
170             I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
171              
172              
173             =head1 REPOSITORY
174              
175             =over
176              
177             =item * Web: L<https://github.com/ikegami/perl-Datetime-Format-Atom>
178              
179             =item * git: L<https://github.com/ikegami/perl-Datetime-Format-Atom.git>
180              
181             =back
182              
183              
184             =head1 AUTHOR
185              
186             Eric Brine, C<< <ikegami@adaelis.com> >>
187              
188              
189             =head1 COPYRIGHT AND LICENSE
190              
191             No rights reserved.
192              
193             The author has dedicated the work to the Commons by waiving all of his
194             or her rights to the work worldwide under copyright law and all related or
195             neighboring legal rights he or she had in the work, to the extent allowable by
196             law.
197              
198             Works under CC0 do not require attribution. When citing the work, you should
199             not imply endorsement by the author.
200              
201              
202             =cut