Skip to content

Commit

Permalink
test for string timezones, fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonjs committed Jan 29, 2014
1 parent 99382d2 commit 0652b28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions strftime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'
Expand All @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')


Expand Down

0 comments on commit 0652b28

Please sign in to comment.