ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/XS.pm
(Generate patch)

Comparing CBOR-XS/XS.pm (file contents):
Revision 1.35 by root, Sun Dec 1 16:40:25 2013 UTC vs.
Revision 1.36 by root, Mon Dec 2 06:37:53 2013 UTC

987 require Time::Piece; 987 require Time::Piece;
988 # Time::Piece::Strptime uses the "incredibly flexible date parsing routine" 988 # Time::Piece::Strptime uses the "incredibly flexible date parsing routine"
989 # from FreeBSD, which can't parse ISO 8601, RFC3339, RFC4287 or much of anything 989 # from FreeBSD, which can't parse ISO 8601, RFC3339, RFC4287 or much of anything
990 # else either. Whats incredibe over standard strptime totally escapes me. 990 # else either. Whats incredibe over standard strptime totally escapes me.
991 # doesn't do fractional times, either. sigh. 991 # doesn't do fractional times, either. sigh.
992 # In fact, it's all a lie, it uses whatever strptime it wants, and of course,
993 # they are all incomptible. The openbsd one simply ignores %z (but according to the
994 # docs, it would be much more incredibly flexible).
992 scalar eval { 995 scalar eval {
993 my $s = $_[1]; 996 my $s = $_[1];
994 997
995 $s =~ s/Z$/+00:00/; 998 $s =~ s/Z$/+00:00/;
996 $s =~ s/(\.[0-9]+)?([+-][0-9][0-9]):([0-9][0-9])/$2$3/ 999 $s =~ s/(\.[0-9]+)?([+-][0-9][0-9]):([0-9][0-9])$//
997 or die; 1000 or die;
998 1001
999 my $f = $1; # fractional part. hopefully 1002 my $b = $1 - ($2 * 60 + $3) * 60; # fractional part + offset. hopefully
1000
1001 my $d = Time::Piece->strptime ($s, "%Y-%m-%dT%H:%M:%S%z"); 1003 my $d = Time::Piece->strptime ($s, "%Y-%m-%dT%H:%M:%S");
1002 1004
1003 Time::Piece::gmtime ($d->epoch + $f) 1005 Time::Piece::gmtime ($d->epoch + $b)
1004 } || die "corrupted CBOR date/time string ($_[0])"; 1006 } || die "corrupted CBOR date/time string ($_[0])";
1005 }, 1007 },
1006 1008
1007 1 => sub { # seconds since the epoch, possibly fractional 1009 1 => sub { # seconds since the epoch, possibly fractional
1008 require Time::Piece; 1010 require Time::Piece;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines