UNPKG

@ribajs/luxon

Version:

Luxon (time library) module for Riba.js

19 lines (17 loc) 640 B
import { Formatter } from "@ribajs/core"; import { DateTime, ToRelativeOptions } from "luxon"; /** * Returns a string representation of a this time relative to now, such as "in two days". */ export const LuxonToRelativeFormatter: Formatter = { name: "lx-to-relative", /** * @see https://moment.github.io/luxon/docs/class/src/datetime.js~DateTime.html#instance-method-toRelative * @param target can be a Luxon DateTime object * @param options ToRelativeOptions | undefined * @returns string | null */ read(target: DateTime, options?: ToRelativeOptions): string | null { return target.toRelative(options); }, };