Files
twenty/packages/twenty-website/src/shared-utils/formatDisplayDate.ts
T
2025-08-11 17:36:53 +02:00

18 lines
481 B
TypeScript

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: isCurrentYear ? 'long' : 'short',
day: 'numeric',
...(isCurrentYear ? {} : { year: 'numeric' }),
});
return formatter.format(date);
};