NAME
XML::Loy::Date::RFC3339 - Date strings according to RFC3339
SYNOPSIS
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;
DESCRIPTION
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.
ATTRIBUTES
XML::Loy::Date::RFC3339 implements the following attributes.
epoch
my $epoch = $date->epoch;
$date = $date->epoch(784111777);
Epoch seconds.
granularity
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
METHODS
XML::Loy::Date::RFC3339 implements the following methods.
new
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.
parse
$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.
to_string
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.
DEPENDENCIES
AVAILABILITY
https://github.com/Akron/XML-Loy
COPYRIGHT AND LICENSE
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.