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

pull/7891/head
胡明昊 2017-10-30 20:53:19 +08:00 committed by 杨奕
parent 5d172ad5cf
commit fecc38f495
1 changed files with 8 additions and 2 deletions

View File

@ -162,8 +162,14 @@ const TYPE_VALUE_RESOLVER_MAP = {
},
week: {
formatter(value, format) {
let date = formatDate(value, format);
const week = getWeekNumber(value);
let 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.replace(/WW/, week < 10 ? '0' + week : week)