mirror of
https://github.com/samsonjs/strftime.git
synced 2026-03-25 09:05:48 +00:00
Fixed tests
This commit is contained in:
parent
05700a7ded
commit
0af3e1ed40
1 changed files with 9 additions and 7 deletions
16
strftime.js
16
strftime.js
|
|
@ -43,12 +43,10 @@
|
|||
// - locale [object] an object with the same structure as DefaultLocale
|
||||
// - timezone [number] timezone offset in minutes from GMT
|
||||
function _strftime(format, date, locale, options) {
|
||||
var m;
|
||||
var o = options || {};
|
||||
var l = locale;
|
||||
var d = date;
|
||||
var i = 0;
|
||||
var r = '';
|
||||
var m, ts, i = 0, r = '';
|
||||
var re = /%([-_0]?)(.)/g;
|
||||
|
||||
if (d && !isDate(d)) {
|
||||
|
|
@ -58,10 +56,12 @@
|
|||
|
||||
l = l || DefaultLocale;
|
||||
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)) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
@ -216,6 +216,8 @@
|
|||
default:
|
||||
return match[0];
|
||||
}
|
||||
} else {
|
||||
p = null;
|
||||
}
|
||||
|
||||
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.
|
||||
function pad(n, padding, length) {
|
||||
var _padding = padding ? '0' : padding;
|
||||
var _padding = padding == null ? '0' : padding;
|
||||
var _n = String(n);
|
||||
var _length = length || 2;
|
||||
|
||||
|
|
@ -303,7 +305,7 @@
|
|||
|
||||
// ISO 8601 format timezone string, [-+]HHMM
|
||||
// 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 tz = opt.timezone;
|
||||
var tzType = typeof tz;
|
||||
|
|
|
|||
Loading…
Reference in a new issue