@ribajs/luxon
Version:
Luxon (time library) module for Riba.js
24 lines (22 loc) • 678 B
text/typescript
import { Formatter } from "@ribajs/core";
import { DateTime, LocaleOptions } from "luxon";
/**
* Returns a string representation of this DateTime formatted according to the specified format string.
*/
export const LuxonToFormatFormatter: Formatter = {
name: "lx-to-format",
/**
* @see https://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html#instance-method-toFormat
* @param target can be a Luxon DateTime object
* @param fmt string
* @param opts Object
* @returns string
*/
read(
target: DateTime,
fmt: string,
opts: LocaleOptions & Intl.DateTimeFormatOptions,
): string {
return target.toFormat(fmt, opts);
},
};