logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

DateTime::Format::RFC3339 - Parse and format RFC3339 datetime strings

Author

       Eric Brine, "<ikegami@adaelis.com>"

Bugs

       Please          report         any         bugs         or         feature         requests         using
       <https://github.com/ikegami/perl-Datetime-Format-RFC3339/issues>.  I will be notified,  and  then  you'll
       automatically be notified of progress on your bug as I make changes.

Constructor

new
          my $format = DateTime::Format::RFC3339->new();
          my $format = DateTime::Format::RFC3339->new( %options );

       A number of options are supported:

       •   decimals

              decimals => undef      [default]
              decimals => $decimals

           Date-time  strings  generated by <format_datetime> will have this many decimals (an integer from zero
           to nine). If "undef", zero will be used if the date-time has no decimals, nine otherwise.

       •   sep

              sep => "T"      [default]
              sep => $sep

       •   sep_re

              sep_re => $sep_re

           The spec allows for a separator other than ""T"" to be used between the date and the time.

           The string provided to the "sep" option is used when formatting date-time objects into  strings,  and
           the  regex  pattern  provided  to  the  "sep_re"  option  is used when parsing strings into date-time
           objects.

           The default for "sep_re" is a regex pattern that matches the separator (which is ""T"" by default).

       •   uc_only

              uc_only => 0   [default]
              uc_only => 1

           Only an uppercase date and time separator and an uppercase timezone offset "Z" will  be  accepted  by
           "parse_datetime" when this option is true.

Description

       This module understands the RFC3339 date/time format, an ISO 8601 profile, defined at
       <http://tools.ietf.org/html/rfc3339>.

       It can be used to parse these formats in order to create the appropriate objects.

Documentation And Support

       You can find documentation for this module with the perldoc command.

           perldoc DateTime::Format::RFC3339

       You can also find it online at this location:

       •   <https://metacpan.org/dist/Datetime-Format-RFC3339>

       If you need help, the following are great resources:

       •   <https://stackoverflow.com/|StackOverflow>

       •   <http://www.perlmonks.org/|PerlMonks>

       •   You may also contact the author directly.

Methods

parse_datetime
          my $dt = DateTime::Format::RFC3339->parse_datetime( $string );
          my $dt = $format->parse_datetime( $string );

       Given a RFC3339 datetime string, this method will return a new DateTime object.

       If given an improperly formatted string, this method will croak.

       For a more flexible parser, see DateTime::Format::ISO8601.

   format_datetime
          my $string = DateTime::Format::RFC3339->format_datetime( $dt );
          my $string = $format->format_datetime( $dt );

       Given a DateTime object, this methods returns a RFC3339 datetime string.

Name

       DateTime::Format::RFC3339 - Parse and format RFC3339 datetime strings

Repository

       •   Web: <https://github.com/ikegami/perl-Datetime-Format-RFC3339>

       •   git: <https://github.com/ikegami/perl-Datetime-Format-RFC3339.git>

See Also

       •   DateTime

       •   DateTime::Format::ISO8601

       •   <http://tools.ietf.org/html/rfc3339>, "Date and Time on the Internet: Timestamps"

Synopsis

          use DateTime::Format::RFC3339;

          my $format = DateTime::Format::RFC3339->new();
          my $dt = $format->parse_datetime( '2002-07-01T13:50:05Z' );

          # 2002-07-01T13:50:05Z
          say $format->format_datetime( $dt );

Version

       Version 1.10.0

See Also