fix(Calendar): getDay 和 getUTCDay 有时间差,导致星期错位 (#4883)

https://github.com/youzan/vant-weapp/issues/4756
This commit is contained in:
xinde 2022-09-07 22:57:45 +08:00 committed by GitHub
parent 9a708747a8
commit 842e88f115
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ var ROW_HEIGHT = 64;
function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) { function getDayStyle(type, index, date, rowHeight, color, firstDayOfWeek) {
var style = []; var style = [];
var current = getDate(date).getDay() || 7; var current = getDate(date).getUTCDay() || 7;
var offset = current < firstDayOfWeek ? (7 - firstDayOfWeek + current) : var offset = current < firstDayOfWeek ? (7 - firstDayOfWeek + current) :
current === 7 && firstDayOfWeek === 0 ? 0 : current === 7 && firstDayOfWeek === 0 ? 0 :
(current - firstDayOfWeek); (current - firstDayOfWeek);