Commit fecc38f4 authored by 胡明昊's avatar 胡明昊 Committed by 杨奕

DatePicker: fix bug for wrong year number when week cross the year like 2014/12/29

parent 5d172ad5
...@@ -162,8 +162,14 @@ const TYPE_VALUE_RESOLVER_MAP = { ...@@ -162,8 +162,14 @@ const TYPE_VALUE_RESOLVER_MAP = {
}, },
week: { week: {
formatter(value, format) { formatter(value, format) {
let date = formatDate(value, format); let week = getWeekNumber(value);
const week = getWeekNumber(value); let month = value.getMonth();
const trueDate = new Date(value);
if (week === 1 && month === 11) {
trueDate.setHours(0, 0, 0, 0);
trueDate.setDate(trueDate.getDate() + 3 - (trueDate.getDay() + 6) % 7);
}
let date = formatDate(trueDate, format);
date = /WW/.test(date) date = /WW/.test(date)
? date.replace(/WW/, week < 10 ? '0' + week : week) ? date.replace(/WW/, week < 10 ? '0' + week : week)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment