Skip to content

Parsing leap seconds #27

@esabol

Description

@esabol

I'm trying to use DateTime::Format::Strptime to parse some date/times, and I can't seem to get it to parse the date/time for leap seconds (e.g., 2012-06-30T23:59:60UTC). The documentation says it supports up to 60 seconds for leap seconds. Am I doing something wrong here or is this a bug?

Here's my code:

use DateTime;
use DateTime::TimeZone;
use DateTime::Format::Strptime;

my $utc = DateTime::TimeZone->new(name => 'Etc/UTC');

my $ymdhms_parser = DateTime::Format::Strptime->new(pattern => '%F %T',
                                                    locale => 'en_US',
                                                    time_zone => $utc,
                                                    strict => 1,
                                                    on_error => 'croak');

print "DateTime $DateTime::VERSION\n";
print "DateTime::LeapSecond $DateTime::LeapSecond::VERSION\n";
print "DateTime::Format::Strptime $DateTime::Format::Strptime::VERSION\n";
my $date = '2012-06-30 23:59:60';
print "date: $date\n";
my $dt = $ymdhms_parser->parse_datetime($date);
print "dt: $dt\n";
print "tz: ",$dt->time_zone,"\n";

The output I get is:

DateTime 1.52
DateTime::LeapSecond 1.52
DateTime::Format::Strptime 1.77
date: 2012-06-30 23:59:60
Parsed values did not produce a valid date at /path/to/test.pl line 17.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions