From 0652b285a76c548d607633099ed27a226b59e7dd Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Wed, 29 Jan 2014 14:42:35 -0800 Subject: [PATCH] test for string timezones, fix a bug --- strftime.js | 8 ++++---- test/test.js | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/strftime.js b/strftime.js index b8f9659..4b50c80 100644 --- a/strftime.js +++ b/strftime.js @@ -50,7 +50,7 @@ timezone = locale; locale = undefined; } - return _strftime(fmt, d, locale, { timezone: timezone, utc: true }); + return _strftime(fmt, d, locale, { timezone: timezone }); } namespace.strftimeUTC = strftime.strftimeUTC = strftimeUTC; @@ -260,8 +260,8 @@ return "GMT"; } else { - var tz = d.toString().match(/\((\w+)\)/); - return tz && tz[1] || ''; + var tzString = d.toString().match(/\((\w+)\)/); + return tzString && tzString[1] || ''; } // '+0000' @@ -270,7 +270,7 @@ return "+0000"; } else { - var off = typeof options.timezone == 'number' ? options.timezone : -d.getTimezoneOffset(); + var off = typeof tz == 'number' ? tz : -d.getTimezoneOffset(); return (off < 0 ? '-' : '+') + pad(Math.abs(off / 60)) + pad(off % 60); } diff --git a/test/test.js b/test/test.js index 72e0243..195187f 100755 --- a/test/test.js +++ b/test/test.js @@ -169,8 +169,11 @@ assert.formatTZ = function(format, expected, tz, time) { } assert.formatTZ('%F %r %z', '2011-06-07 06:51:45 PM +0000', 0) +assert.formatTZ('%F %r %z', '2011-06-07 06:51:45 PM +0000', '+0000') 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') ok('Time zone offset')