File Coverage

blib/lib/DateTime/Format/XSD.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 18 18 100.0


line stmt bran cond sub pod time code
1             package DateTime::Format::XSD;
2             # ABSTRACT: Format DateTime according to xsd:dateTime
3              
4 1     1   810 use strict;
  1         2  
  1         30  
5 1     1   6 use warnings;
  1         2  
  1         30  
6 1     1   5 use base qw(DateTime::Format::ISO8601);
  1         2  
  1         711  
7             our $VERSION = '0.4';
8              
9             sub format_datetime {
10 1     1 1 647 my ($format, $date) = @_;
11 1         5 my $out = $date->strftime('%FT%T%z');
12 1         19 $out =~ s/(\d\d)$/:$1/;
13 1         5 return $out;
14             };
15             1;
16              
17             __END__
18              
19             =pod
20              
21             =encoding UTF-8
22              
23             =head1 NAME
24              
25             DateTime::Format::XSD - Format DateTime according to xsd:dateTime
26              
27             =head1 VERSION
28              
29             version 0.4
30              
31             =head1 SYNOPSIS
32              
33             my $str = DateTime::Format::XSD->format_datetime($dt);
34              
35             =head1 DESCRIPTION
36              
37             XML Schema defines a usage profile which is a subset of the ISO8601
38             profile. This profile defines that the following is the only possible
39             representation for a dateTime, despite all other options ISO provides.
40              
41             YYYY-MM-DD"T"HH:MI:SS(Z|[+-]zh:zm)
42              
43             This module is a subclass of DateTime::Format::ISO8601, therefore it
44             will be able to parse all other ISO options, but will only format it
45             in this exact spec.
46              
47             =head1 SEE ALSO
48              
49             L<DateTime>, L<DateTime::Format::ISO8601>, The XML Schema speficitation.
50              
51             =head1 BUG REPORTS
52              
53             Please submit all bugs regarding C<DateTime::Format::XSD> to
54             C<bug-datetime-format-xsd@rt.cpan.org>
55              
56             =head1 COPYRIGHT
57              
58             This software is copyright (c) 2004 by Daniel Ruoso.
59              
60             =head1 LICENSE
61              
62             This library is free software, you can redistribute it and/or modify
63             it under the same terms as Perl itself.
64              
65             =head1 AUTHORS
66              
67             =over 4
68              
69             =item *
70              
71             Daniel Ruoso <daniel@ruoso.com>
72              
73             =item *
74              
75             Timothy Legge <timlegge@gmail.com>
76              
77             =back
78              
79             =head1 COPYRIGHT AND LICENSE
80              
81             This software is copyright (c) 2021 by Daniel Ruoso.
82              
83             This is free software; you can redistribute it and/or modify it under
84             the same terms as the Perl 5 programming language system itself.
85              
86             =cut