|
|
|
@ -1,18 +1,23 @@ |
|
|
|
|
const { DateTime } = require("luxon") |
|
|
|
|
import { DateTime } from "luxon" |
|
|
|
|
import { useLocale } from "./locale" |
|
|
|
|
|
|
|
|
|
export function useFormatDate() { |
|
|
|
|
const { appParentLocale } = useLocale() |
|
|
|
|
|
|
|
|
|
const abbreviatedDatetime = (datetime) => { |
|
|
|
|
if (!datetime) { |
|
|
|
|
return "" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return DateTime.fromISO(datetime).toLocaleString({ |
|
|
|
|
...DateTime.DATETIME_MED, |
|
|
|
|
month: "long", |
|
|
|
|
}) |
|
|
|
|
return DateTime.fromISO(datetime) |
|
|
|
|
.setLocale(appParentLocale.value) |
|
|
|
|
.toLocaleString({ |
|
|
|
|
...DateTime.DATETIME_MED, |
|
|
|
|
month: "long", |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const relativeDatetime = (datetime) => DateTime.fromISO(datetime).toRelative() |
|
|
|
|
const relativeDatetime = (datetime) => DateTime.fromISO(datetime).setLocale(appParentLocale.value).toRelative() |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
abbreviatedDatetime, |
|
|
|
|