Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed May 21, 2024
2 parents cd44508 + b3f47d5 commit 7aade56
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/utils/datetime.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const locale = 'en-GB';
const timeOptions = { hour: '2-digit', minute: '2-digit', timeZone: 'UTC' };
const dateFullOptions = { dateStyle: 'full' };
const datePatternWithoutComma = /^(\w+) (\d+ \w+ \d+)$/;

/**
* Format date in full format.
Expand All @@ -9,7 +10,13 @@ const dateFullOptions = { dateStyle: 'full' };
* @returns {string} Formatted date
*/
export function formatDateFull(date) {
return date.toLocaleDateString(locale, dateFullOptions);
const formattedDate = date.toLocaleDateString(locale, dateFullOptions);
// insert comma after day name if not already present
const match = datePatternWithoutComma.exec(formattedDate);
if (match) {
return `${match[1]}, ${match[2]}`;
}
return formattedDate;
}

/**
Expand Down

0 comments on commit 7aade56

Please sign in to comment.