From af496003d97e6145ebbfcae14cff039972bc21dd Mon Sep 17 00:00:00 2001 From: mh-zeynal Date: Wed, 29 Nov 2023 16:14:53 +0330 Subject: [PATCH] fix: change schedule tables date format --- .../src/components/item-card/item-card.jsx | 4 ++-- .../src/pages/schedule/useSchedulePage.js | 24 +++++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/item-card/item-card.jsx b/frontend/src/components/item-card/item-card.jsx index b58b189..1a50232 100644 --- a/frontend/src/components/item-card/item-card.jsx +++ b/frontend/src/components/item-card/item-card.jsx @@ -145,10 +145,10 @@ const ItemCard = ({ {Helper.omitLongString(description, 50)} - From: {new Date(startDate).toLocaleString('fa-IR-u-nu-latn')} + From: {new Date(startDate).toLocaleString('fa-IR-u-nu-latn').replace(/:\d{2}$/, '')} - To: {new Date(endDate).toLocaleString('fa-IR-u-nu-latn')} + To: {new Date(endDate).toLocaleString('fa-IR-u-nu-latn').replace(/:\d{2}$/, '')} diff --git a/frontend/src/pages/schedule/useSchedulePage.js b/frontend/src/pages/schedule/useSchedulePage.js index 0ae07b7..bee8681 100644 --- a/frontend/src/pages/schedule/useSchedulePage.js +++ b/frontend/src/pages/schedule/useSchedulePage.js @@ -21,13 +21,15 @@ export default function useSchedulePage() { useEffect(() => { if (workshopsData == null) return setTableWorkshopsData(workshopsData.map(item => { - const startDate = Helper.convertStringToDateWithoutTimezone(item["start_date"]) - const endDate = Helper.convertStringToDateWithoutTimezone(item["end_date"]) + const startDate = new Date(item["start_date"]).toLocaleString('fa-IR-u-nu-latn') + .replace(/:\d{2}$/, '') + const endDate = new Date(item["end_date"]).toLocaleString('fa-IR-u-nu-latn') + .replace(/:\d{2}$/, '') return { Title: item.name, - date: Helper.convertDateTimeToDate(startDate), - Starts: Helper.convertDateTimeToTime(startDate), - Ends: Helper.convertDateTimeToTime(endDate), + date: startDate.split(',')[0], + Starts: startDate.split(',')[1], + Ends: endDate.split(',')[1], } })) }, [workshopsData]) @@ -37,13 +39,15 @@ export default function useSchedulePage() { setTablePresentationsData(presentationsData.filter(element => { return element.name != null }).map(item => { - const startDate = Helper.convertStringToDateWithoutTimezone(item["start_date"]) - const endDate = Helper.convertStringToDateWithoutTimezone(item["end_date"]) + const startDate = new Date(item["start_date"]).toLocaleString('fa-IR-u-nu-latn') + .replace(/:\d{2}$/, '') + const endDate = new Date(item["end_date"]).toLocaleString('fa-IR-u-nu-latn') + .replace(/:\d{2}$/, '') return { Title: item.name, - date: Helper.convertDateTimeToDate(startDate), - Starts: Helper.convertDateTimeToTime(startDate), - Ends: Helper.convertDateTimeToTime(endDate), + date: startDate.split(',')[0], + Starts: startDate.split(',')[1], + Ends: endDate.split(',')[1], } })) }, [presentationsData])