From aa54835a7b835044c179955868f2978cc425f90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 4 Jul 2023 22:22:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=80=E8=BF=91=E5=AD=A6=E4=B9=A0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=94=99=E8=AF=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/study/index.tsx | 22 ++++++++-------------- src/utils/index.ts | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/pages/study/index.tsx b/src/pages/study/index.tsx index 34b6aa5..aca8264 100644 --- a/src/pages/study/index.tsx +++ b/src/pages/study/index.tsx @@ -29,27 +29,21 @@ const StudyPage = () => { let box: CourseModel[] = []; if (data && data.length > 0) { data.map((item: any) => { - if ( - item.hour_record && - moment(item.hour_record.updated_at).isSame(moment(), "day") - ) { + let time = moment(item.hour_record.updated_at) + .utcOffset(0) + .format("YYYY-MM-DD HH:mm:ss"); + if (moment(time).isSame(moment(), "day")) { today.push(item); - } else if ( - item.hour_record && - moment(item.hour_record.updated_at).isSame( - moment().subtract(1, "day"), - "day" - ) - ) { + } else if (moment(time).isSame(moment().subtract(1, "day"), "day")) { yesterday.push(item); } else { box.push(item); } - setTodayCourses(today); - setYesterdayCourses(yesterday); - setCourses(box); }); } + setTodayCourses(today); + setYesterdayCourses(yesterday); + setCourses(box); setLoading(false); }); }; diff --git a/src/utils/index.ts b/src/utils/index.ts index 9471155..38ba46f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -13,7 +13,7 @@ export function clearToken() { } export function dateFormat(dateStr: string) { - return moment(dateStr).format("YYYY-MM-DD HH:mm"); + return moment(dateStr).utcOffset(0).format("YYYY-MM-DD HH:mm"); } export function getHost() {