File: XSD.pm

package info (click to toggle)
libdatetime-format-xsd-perl 0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 160 kB
  • sloc: perl: 80; makefile: 2; sh: 1
file content (86 lines) | stat: -rw-r--r-- 1,723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package DateTime::Format::XSD;
# ABSTRACT: Format DateTime according to xsd:dateTime

use strict;
use warnings;
use base qw(DateTime::Format::ISO8601);
our $VERSION = '0.4';

sub format_datetime {
    my ($format, $date) = @_;
    my $out = $date->strftime('%FT%T%z');
    $out =~ s/(\d\d)$/:$1/;
    return $out;
};
1;

__END__

=pod

=encoding UTF-8

=head1 NAME

DateTime::Format::XSD - Format DateTime according to xsd:dateTime

=head1 VERSION

version 0.4

=head1 SYNOPSIS

  my $str = DateTime::Format::XSD->format_datetime($dt);

=head1 DESCRIPTION

XML Schema defines a usage profile which is a subset of the ISO8601
profile. This profile defines that the following is the only possible
representation for a dateTime, despite all other options ISO provides.

   YYYY-MM-DD"T"HH:MI:SS(Z|[+-]zh:zm)

This module is a subclass of DateTime::Format::ISO8601, therefore it
will be able to parse all other ISO options, but will only format it
in this exact spec.

=head1 SEE ALSO

L<DateTime>, L<DateTime::Format::ISO8601>, The XML Schema speficitation.

=head1 BUG REPORTS

Please submit all bugs regarding C<DateTime::Format::XSD> to
C<bug-datetime-format-xsd@rt.cpan.org>

=head1 COPYRIGHT

    This software is copyright (c) 2004 by Daniel Ruoso.

=head1 LICENSE

This library is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 AUTHORS

=over 4

=item *

Daniel Ruoso <daniel@ruoso.com>

=item *

Timothy Legge <timlegge@gmail.com>

=back

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by Daniel Ruoso.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut