import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; import { DayjsOptions } from './config'; export async function setupDayjs(options: DayjsOptions = { defaultTimezone: '', locales: ['de'] }): Promise { dayjs.extend(utc); dayjs.extend(timezone); if (options.defaultTimezone) { dayjs.tz.setDefault(options.defaultTimezone); } if (options.locales && options.locales.length > 0) { for (const locale of options.locales) { const localeModule: { default: ILocale } = await import(`dayjs/locale/${locale}`); dayjs.locale(localeModule.default.name); } } }