@cute-dw/core
Version:
This TypeScript library is the main part of a more powerfull package designed for the fast WEB software development. The cornerstone of the library is the **DataStore** class, which might be useful when you need a full control of the data, but do not need
147 lines (146 loc) • 6.94 kB
TypeScript
import { Locale } from "../Locale";
import { Time } from "../../type/Time";
import { DateFormat } from "./DateFormat";
export type DateTimeFormatOptions = Intl.DateTimeFormatOptions & {
locales?: string | Locale;
};
export declare const i18n: {
de: {
shortDayNames: string[];
longDayNames: string[];
shortMonthNames: string[];
longMonthNames: string[];
};
en: {
shortDayNames: string[];
longDayNames: string[];
shortMonthNames: string[];
longMonthNames: string[];
};
fr: {
shortDayNames: string[];
longDayNames: string[];
shortMonthNames: string[];
longMonthNames: string[];
};
ru: {
shortDayNames: string[];
longDayNames: string[];
shortMonthNames: string[];
longMonthNames: string[];
};
};
/**
* Java compatible class for date/time formatting subclasses which formats and parses dates and/or time in a language-independent manner.
* Date and time formats are specified by date and time _pattern strings_. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date or time string.
*
* Date and time display formats can have two sections. The first is required and contains the format for dates and times; the second is optional and specifies how to represent nulls:
* `date-time-format;null-format`
*
* Characters with special meaning in _date_ section of display format:
* |Character| Meaning | Example |
* |--- | --- | --- |
* | `d` | Day number with no leading zero | 9 |
* | `dd` | Day number with leading zero if appropriate | 09 |
* | `D` | Day number in year | 189 |
* | `E` | Day name in week, gives starting 1 letter | M |
* | `EEE` | Day name in week, gives starting 2 letters | Mo |
* | `EEE` | Day name in week, gives starting 3 letters | Mon |
* | `EEEE` | Day name in week | Monday |
* | `M` | Month number with no leading zero | 6 |
* | `MM` | Month number with leading zero if appropriate| 06 |
* | `MMM` | Month name abbreviation | Jun |
* | `MMMM` | Month name | June |
* | `yy` | Two-digit year | 97 |
* | `yyyy` | Four-digit year | 1997 |
* | `u` | ISO 8601 day number of the week (1 = Monday, ..., 7 = Sunday) | 1 |
* | `w` | ISO 8601 week number of the year | 8 |
* | `ww` | ISO 8601 week number of the year, leading zero for single-digit | 08 |
* | `W` | ISO 8601 week number of the month | 3 |
* | `WW` | ISO 8601 week number of the month, leading zero for single-digit| 03 |
*
* Colons, slashes, and spaces display as entered in the mask.
*
* You can use the following keywords as date display formats when you want to determine a localized appropriate format to use:
* - [Default]
* - [ShortDate]
* - [MediumDate]
* - [LongDate]
* - [FullDate]
* - [IsoDate]
*
* Note that [Date] is not a valid display format.
*
* Character meaning in _time_ section of the display format:
*
* |Character| Meaning | Example |
* |--- | --- | --- |
* |`h` | Hours; no leading zero for single-digit hours (12-hour clock) | 1 |
* |`hh` | Hours; leading zero for single-digit hours (12-hour clock) | 01 |
* |`H` | Hours; no leading zero for single-digit hours (24-hour clock) | 3 |
* |`HH` | Hours; leading zero for single-digit hours (24-hour clock) | 03 |
* |`m` | Minute with no leading zero (must follow h or hh)| 5 |
* |`mm` | Minute with leading zero if appropriate (must follow h or hh)| 05 |
* |`s` | Second with no leading zero (must follow m or mm)| 7 |
* |`ss` | Second with leading zero (must follow m or mm) | 07 |
* |`S` | Milliseconds; gives 1 digits | 3 |
* |`SS` | Milliseconds; gives 2 digits | 25 |
* |`SSS` | Milliseconds; gives 3 digits | 248 |
* |`a` | Am/pm marker in lower case | am |
* |`A` | Am/pm marker in upper case | PM |
* |`z` | Timezone abbreviation, e.g. GMT+0700, UTC | GMT-05:00 |
* |`Z` | RFC 822 timezone offset, e.g. -0500 or +0230 | +0400 |
* |`X` | ISO 8601 timezone offset, e.g. Z, +04 | +04 |
* |`XX` | ISO 8601 timezone offset, e.g. Z, -0500 | +0400 |
* |`XXX` | ISO 8601 timezone offset, e.g. Z, +02:30 | +04:00|
* |`TT` | Time between the date and the current date (narrow style)| -8 h |
* |`TTT` | Time between the date and the current date (short style) | in 10 hr. |
* |`TTTT` | Time between the date and the current date (long style) | in 10 hours |
*
* Colons, slashes, and spaces display as entered in the mask.
*
* You can use the following keywords as a time display formats when you want to determine a localized appropriate format to use:
* - [Time]
* - [ShortTime]
* - [LongTime]
* - [IsoTime]
* - [LongTimeAgo]
* - [ShortTimeAgo]
*
* For display both date and time values apply the following keywords:
* - [DateTime]
* - [IsoDateTime]
* - [IsoDateTimeTZ]
* - [IsoDateTimeUTC]
* @example
* console.log( new DateTimeFormat("EEEE, MMMM dd, yyyy, h:mm:ss a").format(Date.now()) ); // Saturday, June 09, 2007, 5:46:21 PM
* @since 0.5.0
* @license MIT, (c) 2022 ALEXANDER STRELKOV, alv.strelkov@gmail.com
*/
export declare class SimpleDateFormat extends DateFormat {
private _dtFormatter;
private _rtFormatter;
private _options;
private _locale;
private _pattern;
private _subpatterns;
private _utcgmt;
constructor(pattern?: string, options?: DateTimeFormatOptions);
private _decompose;
private formatTimeAgo;
/**
* Get proper timezone abbreviation or timezone offset.
*
* This will fall back to `GMT+xxxx` if it does not recognize the
* timezone within the `timezone` RegEx above. Currently only common
* American and Australian timezone abbreviations are supported.
*
* @param {String | Date} date
* @return {String}
*/
static formatTimezone(date: Date): string;
/**
* @override
*/
format(value: Date | Time | string | number | null): string;
}