Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ten-taxes-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Update shortDate modifier to include year for future dates.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ const weekday = (val: Date | string | number, locale?: string, weekday?: 'long'
}
};

/**
* Returns a short date string if the current year is the same as the date's year,
* otherwise returns a long date string.
*/
const shortDate = (val: Date | string | number, locale?: string) => {
const date = normalizeDate(val);
try {
return new Intl.DateTimeFormat(locale || 'en-US', {
month: 'short',
day: 'numeric',
...(date.getFullYear() !== new Date().getFullYear() ? { year: 'numeric' } : {}),
}).format(normalizeDate(val));
} catch (e) {
console.warn(e);
Expand Down