The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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 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);

Construct 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);

Parse RFC3339 and granularity compliant date strings. Also accepts epoch seconds.

to_string

  my $string = $date->to_string;
  my $string = $date->to_string(3);

Render date suitable to RFC3339 without offset information. Takes an optional parameter for granularity. Uses the objects granularity level by default.

DEPENDENCIES

Time::Local.

COPYRIGHT AND LICENSE

The code is heavily based on Mojo::Date, written by Sebastian Riedel. See Mojo::Date for additional copyright and license information.

AVAILABILITY

  https://github.com/Akron/XML-Loy

Copyright (C) 2011-2013, Nils Diewald.

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