55 lines
1.1 KiB
TypeScript
55 lines
1.1 KiB
TypeScript
|
|
import { DateTime } from 'luxon';
|
|
|
|
export function now(zone?: string) {
|
|
return zone
|
|
? DateTime.now().setZone(zone)
|
|
: DateTime.now();
|
|
}
|
|
|
|
export function from_iso(time: string, zone?: string) {
|
|
return zone
|
|
? DateTime.fromISO(time, { zone })
|
|
: DateTime.fromISO(time);
|
|
}
|
|
|
|
// function date_formatters(lang: string, time_zone: string) {
|
|
// return {
|
|
// date() {
|
|
// return (text, render) => {
|
|
// return format_with_config(render(text), {
|
|
// dateStyle: 'short',
|
|
// timeZone: time_zone,
|
|
// });
|
|
// };
|
|
// },
|
|
// time() {
|
|
// return (text, render) => {
|
|
// return format_with_config(render(text), {
|
|
// timeStyle: 'long',
|
|
// timeZone: time_zone,
|
|
// });
|
|
// };
|
|
// },
|
|
// datetime() {
|
|
// return (text, render) => {
|
|
// return format_with_config(render(text), {
|
|
// dateStyle: 'short',
|
|
// timeStyle: 'long',
|
|
// timeZone: time_zone,
|
|
// });
|
|
// };
|
|
// },
|
|
// };
|
|
|
|
// function format_with_config(text: string, config: Intl.DateTimeFormatOptions) {
|
|
// const date = new Date(text.trim());
|
|
// const formatter = new Intl.DateTimeFormat(lang, config);
|
|
// return formatter.format(date);
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
|