@@ -2,11 +2,15 @@ export const formatGithubPublishedAtDisplayDate = (
|
||||
dateString: string,
|
||||
): string => {
|
||||
const date = new Date(dateString);
|
||||
if (Number.isNaN(date.getTime())) return '';
|
||||
|
||||
const now = new Date();
|
||||
const isCurrentYear = date.getFullYear() === now.getFullYear();
|
||||
|
||||
const formatter = new Intl.DateTimeFormat('en-US', {
|
||||
month: 'short',
|
||||
month: isCurrentYear ? 'long' : 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
...(isCurrentYear ? {} : { year: 'numeric' }),
|
||||
});
|
||||
|
||||
return formatter.format(date);
|
||||
|
||||
Reference in New Issue
Block a user