Skip to content

Commit

Permalink
fixed offset handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 21, 2014
1 parent a9d9168 commit 4ef8d23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/Date.pm
Expand Up @@ -34,7 +34,7 @@ sub parse {
# RFC 3339 (1994-11-06T08:49:37Z)
elsif ($date =~ $RFC3339_RE) {
($year, $month, $day, $h, $m, $s) = ($1, $2 - 1, $3, $4, $5, $6);
$offset = (($8 * 3600) + ($9 * 60)) * ($7 eq '-' ? -1 : 1) if $7;
$offset = (($8 * 3600) + ($9 * 60)) * ($7 eq '+' ? -1 : 1) if $7;
}

# RFC 850/1036 (Sunday, 06-Nov-94 08:49:37 GMT)
Expand Down
14 changes: 7 additions & 7 deletions t/mojo/date.t
Expand Up @@ -17,15 +17,15 @@ is(Mojo::Date->new(1408567500)->to_datetime,
is(Mojo::Date->new('2014-08-20T20:45:00.01')->epoch,
1408567500, 'right epoch value');
is(Mojo::Date->new('2014-08-20T20:45:00-00:46')->epoch,
1408564740, 'right epoch value');
is(Mojo::Date->new(1408564740)->to_datetime,
'2014-08-20T19:59:00Z', 'right format');
1408570260, 'right epoch value');
is(Mojo::Date->new(1408570260)->to_datetime,
'2014-08-20T21:31:00Z', 'right format');
is(Mojo::Date->new('2014-08-20t20:45:00-01:46')->epoch,
1408561140, 'right epoch value');
is(Mojo::Date->new('2014-08-20t20:45:00+01:46')->epoch,
1408573860, 'right epoch value');
is(Mojo::Date->new(1408573860)->to_datetime,
'2014-08-20T22:31:00Z', 'right format');
is(Mojo::Date->new('2014-08-20t20:45:00+01:46')->epoch,
1408561140, 'right epoch value');
is(Mojo::Date->new(1408561140)->to_datetime,
'2014-08-20T18:59:00Z', 'right format');
is(Mojo::Date->new('1994-11-06T08:49:37Z')->epoch,
784111777, 'right epoch value');
is(Mojo::Date->new('1994-11-06t08:49:37.33z')->epoch,
Expand Down

0 comments on commit 4ef8d23

Please sign in to comment.