| 1 |
package DateTime::Format::XSD; |
| 2 |
# ABSTRACT: Format DateTime according to xsd:dateTime |
| 3 |
|
| 4 |
use strict; |
| 5 |
use warnings; |
| 6 |
use base qw(DateTime::Format::ISO8601); |
| 7 |
our $VERSION = '0.4'; |
| 8 |
|
| 9 |
sub format_datetime { |
| 10 |
my ($format, $date) = @_; |
| 11 |
my $out = $date->strftime('%FT%T%z'); |
| 12 |
$out =~ s/(\d\d)$/:$1/; |
| 13 |
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<[email protected]> |
| 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 <[email protected]> |
| 72 |
|
| 73 |
=item * |
| 74 |
|
| 75 |
Timothy Legge <[email protected]> |
| 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 |