Skip to content

Commit

Permalink
Merge pull request samsonjs#40 from alexandrnikitin/Issue39_BugInPart…
Browse files Browse the repository at this point in the history
…ialHourTimezone

Fix for samsonjs#39 bug in partial hour timezones
  • Loading branch information
samsonjs committed Jun 17, 2014
2 parents 90ec02d + dfeb3f8 commit 50a267b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions strftime.js
Expand Up @@ -103,7 +103,7 @@
var sign = tz[0] == '-' ? -1 : 1;
var hours = parseInt(tz.slice(1, 3), 10);
var mins = parseInt(tz.slice(3, 5), 10);
tz = sign * (60 * hours) + mins;
tz = sign * ((60 * hours) + mins);
}

if (tzType) {
Expand Down Expand Up @@ -271,7 +271,7 @@
}
else {
var off = typeof tz == 'number' ? tz : -d.getTimezoneOffset();
return (off < 0 ? '-' : '+') + pad(Math.abs(off / 60)) + pad(off % 60);
return (off < 0 ? '-' : '+') + pad(Math.floor(Math.abs(off) / 60)) + pad(Math.abs(off) % 60);
}

default: return c;
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Expand Up @@ -173,6 +173,7 @@ assert.formatTZ('%F %r %z', '2011-06-07 08:51:45 PM +0200', 120)
assert.formatTZ('%F %r %z', '2011-06-07 08:51:45 PM +0200', '+0200')
assert.formatTZ('%F %r %z', '2011-06-07 11:51:45 AM -0700', -420)
assert.formatTZ('%F %r %z', '2011-06-07 11:51:45 AM -0700', '-0700')
assert.formatTZ('%F %r %z', '2011-06-07 11:21:45 AM -0730', '-0730')
ok('Time zone offset')


Expand Down

0 comments on commit 50a267b

Please sign in to comment.