@aotearoan/neon
Version:
Neon is a lightweight design library of Vue 3 components with minimal dependencies.
80 lines (79 loc) • 4.06 kB
TypeScript
import type { NeonCalendarConfig } from '@/model/user-input/calendar/NeonCalendarConfig';
import type { NeonDate } from '@/model/common/date/NeonDate';
/**
* Date utilities for general application use as well as internally with the
* <a href="/user-input/date-picker">NeonDatePicker</a> component.
*/
export declare class NeonDateUtils {
/**
* Format a Date object as a locale formatted date with a three letter month and a 2 digit day.
* @param value The date to format.
*/
static formatDate(value: Date): string;
/**
* Format an ISO 8601 string to a locale formatted date with a three letter month and a 2 digit day and the time.
* @param value ISO date string
* @param seconds boolean indicating whether to display seconds
*/
static formatISOStringToDateAndTime(value: string, seconds?: boolean): string;
/**
* Convert an ISO 8601 formatted string to a locale formatted date with a three letter month, a 2 digit day and a locale formatted time.
*
* @param date The date/time as an <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> string.
* @param locale The locale for which to convert the date for display purposes, defaults to browser locale.
* @param strict Do not add time component to localise the date.
*
* @returns Object representing the provided date.
*/
static stringToNeonDate(date: string, locale?: string, strict?: boolean): NeonDate;
/**
* Convert a date object to an ISO 8601 formatted string. By default, the time is not considered.
*
* @param date Javascript date object.
* @param time Whether to consider the time as part of the conversion to the ISO string.
*
* @returns an ISO 8601 formatted date, optionally with the time as well.
*/
static dateToIso(date: Date, time?: boolean): string;
/**
* Convert the params received into an ISO 8601 formatted string with only date in it.
*
* @param day The number of the day to be used.
* @param month The number of the month to be used.
* @param year The number of the year to be used.
*
* @returns an ISO 8601 formatted date for the given parameters.
*/
static dmyToIso(day: number, month: number, year: number): string;
/**
* Returns the days of the week starting at Monday day name translated using the locale received as a first element.
*
* @param locale The locale for which to convert the date for display purposes, defaults to browser locale.
* @param format The format of the returned values
*
* @returns an array with the days of the week named according to the locale received.
*/
static dowNames(locale?: string, format?: 'long' | 'short' | 'narrow'): Array<string>;
/**
* Returns the months of the year starting at January month name translated using the locale received as a first element.
*
* @param locale The locale for which to convert the date for display purposes, defaults to browser locale.
* @param format The format of the month names to return
*
* @returns an array with the month names of the year, all named according to the locale received.
*/
static monthNames(locale?: string, format?: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow'): Array<string>;
/**
* Collate & return the data required to drive the calendar popup in
* <a href="/user-input/date-picker">NeonDatePicker</a>.
*
* @param selectedDate ISO-8601 date-only string for the selected date.
* @param currentPageMonth month of the current calendar page.
* @param currentPageYear year of the current calendar page.
* @param currentPageDecadeStart decade start year of the current calendar page.
* @param locale user's locale.
*
* @returns The calendar configuration.
*/
static toCalendarConfiguration(selectedDate?: string, currentPageMonth?: number, currentPageYear?: number, currentPageDecadeStart?: number, locale?: string): NeonCalendarConfig;
}