The interface was translated in en/it/es/fr via @nuxtjs/i18n. Drop the module, the locale files, and the language switcher: the UI is now static Italian text, with translation for foreign visitors left to the Google Translate browser extension instead of the app.
18 lines
746 B
TypeScript
18 lines
746 B
TypeScript
/** Human-readable date for display; returns an empty string when unset. */
|
|
export function formatDate(value: string | null | undefined): string {
|
|
if (!value) return ''
|
|
return new Intl.DateTimeFormat('it-IT', { dateStyle: 'long' }).format(new Date(value))
|
|
}
|
|
|
|
/** Date and time of publication, shown in the article byline. */
|
|
export function formatDateTime(value: string | null | undefined): string {
|
|
if (!value) return ''
|
|
return new Intl.DateTimeFormat('it-IT', { dateStyle: 'long', timeStyle: 'short' })
|
|
.format(new Date(value))
|
|
}
|
|
|
|
/** Machine-readable date for the `datetime` attribute and structured data. */
|
|
export function isoDate(value: string | null | undefined): string {
|
|
return value ? new Date(value).toISOString() : ''
|
|
}
|