DateTime::Format::Strptime - Parse and format strp and strf time patterns


NAME

DateTime::Format::Strptime - Parse and format strp and strf time patterns


SYNOPSIS

  use DateTime::Format::Strptime;
  my $Strp = new DateTime::Format::Strptime(
                                pattern     => '%T',
                                locale      => 'en_AU',
                                time_zone   => 'Australia/Melbourne',
                        );
  my $dt = $Strp->parse_datetime('23:16:42');
  $Strp->format_datetime($dt);
        # 23:16:42
  # Croak when things go wrong:
  my $Strp = new DateTime::Format::Strptime(
                                pattern         => '%T',
                                locale      => 'en_AU',
                                time_zone       => 'Australia/Melbourne',
                                on_error        => 'croak',
                        );
  $newpattern = $Strp->pattern('%Q');
  # Unidentified token in pattern: %Q in %Q at line 34 of script.pl
  # Do something else when things go wrong:
  my $Strp = new DateTime::Format::Strptime(
                                pattern         => '%T',
                                locale      => 'en_AU',
                                time_zone       => 'Australia/Melbourne',
                                on_error        => \&phone_police,
                        );


DESCRIPTION

This module implements most of strptime(3), the POSIX function that is the reverse of strftime(3), for DateTime. While strftime takes a DateTime and a pattern and returns a string, strptime takes a string and a pattern and returns the DateTime object associated.


CONSTRUCTOR


METHODS

This class offers the following methods.


EXPORTS

There are no methods exported by default, however the following are available:


STRPTIME PATTERN TOKENS

The following tokens are allowed in the pattern string for strptime (parse_datetime):


RESOURCES


LICENSE AND COPYRIGHT

Copyright © Rick Measham, 2003-2007. All rights reserved.

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

The full text of the licenses can be found in the LICENCE file included with this module.


AUTHOR

Rick Measham <rickm@cpan.org>


SEE ALSO

datetime@perl.org mailing list.

http://datetime.perl.org/

the perl manpage, DateTime, the DateTime::TimeZone manpage

 DateTime::Format::Strptime - Parse and format strp and strf time patterns