Fixed tests

This commit is contained in:
B~Vladi 2014-05-15 02:28:07 +04:00
parent 05700a7ded
commit 0af3e1ed40

View file

@ -43,12 +43,10 @@
// - locale [object] an object with the same structure as DefaultLocale // - locale [object] an object with the same structure as DefaultLocale
// - timezone [number] timezone offset in minutes from GMT // - timezone [number] timezone offset in minutes from GMT
function _strftime(format, date, locale, options) { function _strftime(format, date, locale, options) {
var m;
var o = options || {}; var o = options || {};
var l = locale; var l = locale;
var d = date; var d = date;
var i = 0; var m, ts, i = 0, r = '';
var r = '';
var re = /%([-_0]?)(.)/g; var re = /%([-_0]?)(.)/g;
if (d && !isDate(d)) { if (d && !isDate(d)) {
@ -58,10 +56,12 @@
l = l || DefaultLocale; l = l || DefaultLocale;
l.formats = l.formats || {}; l.formats = l.formats || {};
d = fixTimeZone(d || new Date(), o); d = d || new Date();
ts = d.getTime();
d = fixTZ(d, o);
while (m = re.exec(format)) { while (m = re.exec(format)) {
r += format.substring(i, m.index) + match(m, d, l, d.getTime(), o); r += format.substring(i, m.index) + match(m, d, l, ts, o);
i = m.index + m[0].length; i = m.index + m[0].length;
} }
@ -216,6 +216,8 @@
default: default:
return match[0]; return match[0];
} }
} else {
p = null;
} }
return mask[c] ? mask[c](p, date, locale, timestamp, options) : c; return mask[c] ? mask[c](p, date, locale, timestamp, options) : c;
@ -227,7 +229,7 @@
// Default padding is '0' and default length is 2, both are optional. // Default padding is '0' and default length is 2, both are optional.
function pad(n, padding, length) { function pad(n, padding, length) {
var _padding = padding ? '0' : padding; var _padding = padding == null ? '0' : padding;
var _n = String(n); var _n = String(n);
var _length = length || 2; var _length = length || 2;
@ -303,7 +305,7 @@
// ISO 8601 format timezone string, [-+]HHMM // ISO 8601 format timezone string, [-+]HHMM
// Convert to the number of minutes and it'll be applied to the date below. // Convert to the number of minutes and it'll be applied to the date below.
function fixTimeZone(date, opt) { function fixTZ(date, opt) {
var d = date; var d = date;
var tz = opt.timezone; var tz = opt.timezone;
var tzType = typeof tz; var tzType = typeof tz;