Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6584874

Browse files
committed
format dates correctly
1 parent6367b41 commit6584874

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎frontend/src/components/Event/EventsCarousel.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,17 @@ const formatEventDate = (startTime: string, endTime: string): string => {
6262
conststartDate=newDate(startTime);
6363
constendDate=newDate(endTime);
6464

65-
constsameDay=startDate.toDateString()===endDate.toDateString();
65+
constoptions:Intl.DateTimeFormatOptions={day:'2-digit',month:'2-digit',year:'numeric'};
66+
67+
constformatDate=(date:Date):string=>{
68+
returnnewIntl.DateTimeFormat('en-AU',options).format(date).replace(/\//g,'/');
69+
};
6670

71+
constsameDay=startDate.toDateString()===endDate.toDateString();
72+
6773
if(sameDay){
68-
returnstartDate.toLocaleDateString();
74+
returnformatDate(startDate);// Return single date in dd/mm/yyyy
6975
}else{
70-
return`${startDate.toLocaleDateString()} -${endDate.toLocaleDateString()}`;
76+
return`${formatDate(startDate)} -${formatDate(endDate)}`;// Return date range
7177
}
72-
};
78+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp