XML::Loy::Date::RFC3339 - Date strings according to RFC3339
use XML::Loy::Date::RFC3339; my $date = XML::Loy::Date::RFC3339->new(784111777); my $date_str = $date->to_string; $date->parse('1993-01-01t18:50:00-04:00'); my $epoch = $date->epoch;
XML::Loy::Date::RFC3339 implements date and time functions according to RFC3339. In addition to that it supports granularity as described in W3C date and time formats.
This module is meant to be compatible with the Mojo::Date-API but has no Mojo dependencies.
This module is EXPERIMENTAL and may be changed, replaced or renamed without warnings.
XML::Loy::Date::RFC3339 implements the following attributes.
my $epoch = $date->epoch; $date = $date->epoch(784111777);
Epoch seconds.
my $granularity = $date->granularity; $date->granulariy(3);
Level of granularity.
0: Complete date plus hours, minutes and seconds
1: Complete date plus hours and minutes
2: Complete date
3: Year and month
4: Year
XML::Loy::Date::RFC3339 implements the following methods.
my $date = XML::Loy::Date::RFC3339->new; my $date = XML::Loy::Date::RFC3339->new($string);
Constructs a new XML::Loy::Date::RFC3339 object. Accepts a date string to be parsed.
$date = $date->parse('1993-01-01t18:50:00-04:00'); $date = $date->parse('1993-01-01'); $date = $date->parse(1312043400);
Parses RFC3339 and granularity compliant date strings. Also accepts epoch seconds.
my $string = $date->to_string; my $string = $date->to_string(3);
Renders date suitable to RFC3339 without offset information. Takes an optional parameter for granularity. Uses the objects granularity level by default.
Time::Local.
https://github.com/Akron/XML-Loy
Copyright (C) 2011-2021, Nils Diewald.
The code is heavily based on Mojo::Date, written by Sebastian Riedel. See Mojo::Date for additional copyright and license information.
This program is free software, you can redistribute it and/or modify it under the same terms as Perl.
To install XML::Loy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Loy
CPAN shell
perl -MCPAN -e shell install XML::Loy
For more information on module installation, please visit the detailed CPAN module installation guide.