Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

490 B
Raw Blame
export function createDateFormatter({ locale }: { locale: string }) {
  const defaultFormatter = new Intl.DateTimeFormat(locale, {
    year: 'numeric',
    month: 'short',
    day: 'numeric',
  });

  // Custom options replace the defaults so dateStyle/timeStyle can also be used.
  return (date: Date, options?: Intl.DateTimeFormatOptions): string => {
    const formatter = options ? new Intl.DateTimeFormat(locale, options) : defaultFormatter;

    return formatter.format(date);
  };
}