AC-DC
view release on metacpan or search on metacpan
lib/AC/ISOTime.pm view on Meta::CPAN
$iso =~ s/^\s+//g; # Ensure no leading spaces can throw off the split
my($date, $time) = split /T|\s/, $iso, 2;
$time =~ s/\s//g;
$time ||= '00:00:00Z';
my($year, $mon, $day) = $date =~ /(\d{4})-?(\d{2})-?(\d{2})?/;
$day ||= 1; # day is optional
($time, my $tz) = $time =~ /([^-+Z]+)(.*)/;
my($hr, $min, $sec) = $time =~ /(\d{2}):?(\d{2}):?(.*)/;
($sec, my $frac) = $sec =~ /(\d+)(\.\d+)?/;
my($tzsign, $tzhr, $tzmin) = $tz =~ /(-?)(\d{2}):?(\d{2})?/;
$tzmin ||= 0;
$tzhr = $tzmin = 0 if $tz eq 'Z';
my $t = timegm($sec,$min,$hr, $day, $mon-1, $year);
$t += $frac;
$t -= (3600 * $tzhr + 60 * $tzmin) * ($tzsign ? -1 : 1);
return $t;
}
1;
( run in 0.580 second using v1.01-cache-2.11-cpan-39bf76dae61 )