mirror of
https://github.com/samsonjs/strftime.git
synced 2026-03-25 09:05:48 +00:00
test for string timezones, fix a bug
This commit is contained in:
parent
99382d2d5e
commit
0652b285a7
2 changed files with 7 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue