|
|
@ -17835,21 +17835,16 @@ _.extend(BI, { |
|
|
|
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); |
|
|
|
var d = BI.getDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); |
|
|
|
var week = d.getDay(); |
|
|
|
var week = d.getDay(); |
|
|
|
var startOfWeek = BI.StartOfWeek % 7; |
|
|
|
var startOfWeek = BI.StartOfWeek % 7; |
|
|
|
if (date.getMonth() === 0) { |
|
|
|
var middleDay = (startOfWeek + 3) % 7; |
|
|
|
var formatWeek = (week + 8 - startOfWeek) % 7; |
|
|
|
middleDay = middleDay || 7; |
|
|
|
if(date.getDate() <= (formatWeek === 0 ? 7 : formatWeek)) { |
|
|
|
// 偏移到周周首之前需要多少天
|
|
|
|
return 1; |
|
|
|
var offsetWeekStartCount = week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek); |
|
|
|
} |
|
|
|
var offsetWeekMiddleCount = middleDay < startOfWeek ? (7 + middleDay - startOfWeek) : (middleDay - startOfWeek); |
|
|
|
} |
|
|
|
d.setDate(d.getDate() - offsetWeekStartCount + offsetWeekMiddleCount); |
|
|
|
d.setDate(date.getDate() - (week < startOfWeek ? (7 + week - startOfWeek) : (week - startOfWeek))); |
|
|
|
var ms = d.valueOf(); |
|
|
|
var ms = d.valueOf(); // GMT
|
|
|
|
|
|
|
|
d.setMonth(0); |
|
|
|
d.setMonth(0); |
|
|
|
d.setDate(1); |
|
|
|
d.setDate(1); |
|
|
|
var offset = Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; |
|
|
|
return Math.floor((ms - d.valueOf()) / (7 * 864e5)) + 1; |
|
|
|
if (d.getDay() !== startOfWeek) { |
|
|
|
|
|
|
|
offset++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return offset; |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
getQuarter: function (date) { |
|
|
|
getQuarter: function (date) { |
|
|
@ -17998,7 +17993,27 @@ _.extend(BI, { |
|
|
|
return s[par] || par; |
|
|
|
return s[par] || par; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 包含年周的格式化,ISO8601标准周的计数会影响年
|
|
|
|
|
|
|
|
if ((str.indexOf("%Y") !== -1 || str.indexOf("%y") !== -1) && (str.indexOf("%W") !== -1 || str.indexOf("%U") !== -1 || str.indexOf("%V") !== -1)) { |
|
|
|
|
|
|
|
switch (wn) { |
|
|
|
|
|
|
|
// 如果周数是1,但是当前却在12月,表示此周数为下一年的
|
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
if (m === 11) { |
|
|
|
|
|
|
|
s["%y"] = parseInt(s["%y"]) + 1; |
|
|
|
|
|
|
|
s["%Y"] = parseInt(s["%Y"]) + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
// 如果周数是53,但是当前却在1月,表示此周数为上一年的
|
|
|
|
|
|
|
|
case 53: |
|
|
|
|
|
|
|
if (m === 0) { |
|
|
|
|
|
|
|
s["%y"] = parseInt(s["%y"]) - 1; |
|
|
|
|
|
|
|
s["%Y"] = parseInt(s["%Y"]) - 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
var a = str.match(re); |
|
|
|
var a = str.match(re); |
|
|
|
for (var i = 0; i < a.length; i++) { |
|
|
|
for (var i = 0; i < a.length; i++) { |
|
|
|
var tmp = s[a[i]]; |
|
|
|
var tmp = s[a[i]]; |
|
|
|