date-vir
Version:
Easy and explicit dates and times.
59 lines (58 loc) • 1.62 kB
TypeScript
import { type PartialWithUndefined } from '@augment-vir/common';
import { type FullDate } from '../full-date/full-date-shape.js';
/**
* Converts the given {@link FullDate} into a string based the user's locale, or the given locale
* options.
*
* @category Formatting
* @example
*
* ```ts
* import {toLocaleString} from 'date-vir';
*
* ToLocaleString({
* year: 2024,
* month: 9,
* day: 25,
* hour: 0,
* minute: 0,
* second: 0,
* millisecond: 0,
* });
* // `'9/25/2024'` in my locale, yours may be different
* ```
*/
export declare function toLocaleString(fullDate: FullDate,
/** Defaults to using the user's own locale. */
formatOptions?: (Intl.DateTimeFormatOptions & PartialWithUndefined<{
locale: string;
}>) | undefined): string;
/**
* Provides arbitrary date formatting control (using Luxon under the hood). For full details on the
* options for format control, see https://moment.github.io/luxon/#/formatting?id=table-of-tokens
*
* In most cases you should prefer {@link toLocaleString} so your users see the format they expect.
* {@link toLocaleString} already has many formatting options.
*
* @category Formatting
* @example
*
* ```ts
* import {toFormattedString} from 'date-vir';
*
* toFormattedString(
* {
* year: 2024,
* month: 9,
* day: 25,
* hour: 0,
* minute: 0,
* second: 0,
* millisecond: 0,
* },
* 'MMM-yyyy',
* );
* // `'Sep-2024'`
* ```
*/
export declare function toFormattedString(fullDate: FullDate, format: string, localeOverride?: string): string;