diff --git a/strftime.js b/strftime.js index b1be0ab..1d0afa1 100644 --- a/strftime.js +++ b/strftime.js @@ -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) { @@ -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; diff --git a/test/test.js b/test/test.js index 3508855..96a10ec 100755 --- a/test/test.js +++ b/test/test.js @@ -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')