Skip to content

Johan/intl datetimeformatoptions #38521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions lib/lib.es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4297,20 +4297,34 @@ declare namespace Intl {
supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[];
};

type DateFormatNumericVerbosity = "numeric" | "2-digit";
type DateFormatNameVerbosity = "long" | "short" | "narrow";

interface DateTimeFormatOptions {
localeMatcher?: string;
weekday?: string;
era?: string;
year?: string;
month?: string;
day?: string;
hour?: string;
minute?: string;
second?: string;
timeZoneName?: string;
formatMatcher?: string;
/** output examples – numeric: "2020", 2-digit: "20" */
year?: DateFormatNumericVerbosity;
/** output examples – numeric: "3", 2-digit: "03", long: "March", short: "Mar", narrow: "M" */
month?: DateFormatNumericVerbosity | DateFormatNameVerbosity;
/** output examples – numeric: "2", 2-digit: "02" */
day?: DateFormatNumericVerbosity;
/** output examples – numeric: "2", 2-digit: "02" */
hour?: DateFormatNumericVerbosity;
/** output examples – numeric: "2", 2-digit: "02" */
minute?: DateFormatNumericVerbosity;
/** output examples – numeric: "2", 2-digit: "02" */
second?: DateFormatNumericVerbosity;
/** output examples – long: "Thursday", short: "Thu", narrow: "T" */
weekday?: DateFormatNameVerbosity;
/** output examples – long: "Anno Domini", short: "AD", narrow "A" */
era?: DateFormatNameVerbosity;
/** set to `true` to force 12-hour am/pm "dayPeriod" values, or `false` to force 24-hour time without */
hour12?: boolean;
/** output examples – long: "Pacific Daylight Time", short: "PDT" */
timeZoneName?: "long" | "short";
/** set to the timezone name you want to render date and time for, e g "UTC", "Europe/Rome" */
timeZone?: string;
localeMatcher?: "best fit" | "lookup";
formatMatcher?: "best fit" | "basic";
}

interface ResolvedDateTimeFormatOptions {
Expand Down
36 changes: 25 additions & 11 deletions tests/lib/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3927,20 +3927,34 @@ declare module Intl {
supportedLocalesOf(locale: string, options?: NumberFormatOptions): string[];
}

type DateFormatNumericVerbosity = "numeric" | "2-digit";
type DateFormatNameVerbosity = "long" | "short" | "narrow";

interface DateTimeFormatOptions {
localeMatcher?: string;
weekday?: string;
era?: string;
year?: string;
month?: string;
day?: string;
hour?: string;
minute?: string;
second?: string;
timeZoneName?: string;
formatMatcher?: string;
/** output examples – numeric: "2020", 2-digit: "20" */
year?: DateFormatNumericVerbosity;
/** output examples – numeric: "3", 2-digit: "03", long: "March", short: "Mar", narrow: "M" */
month?: DateFormatNumericVerbosity | DateFormatNameVerbosity;
/** output examples – numeric: "2", 2-digit: "02" */
day?: DateFormatNumericVerbosity;
/** output examples – numeric: "2", 2-digit: "02" */
hour?: DateFormatNumericVerbosity;
/** output examples – numeric: "2", 2-digit: "02" */
minute?: DateFormatNumericVerbosity;
/** output examples – numeric: "2", 2-digit: "02" */
second?: DateFormatNumericVerbosity;
/** output examples – long: "Thursday", short: "Thu", narrow: "T" */
weekday?: DateFormatNameVerbosity;
/** output examples – long: "Anno Domini", short: "AD", narrow "A" */
era?: DateFormatNameVerbosity;
/** set to `true` to force 12-hour am/pm "dayPeriod" values, or `false` to force 24-hour time without */
hour12?: boolean;
/** output examples – long: "Pacific Daylight Time", short: "PDT" */
timeZoneName?: "long" | "short";
/** set to the timezone name you want to render date and time for, e g "UTC", "Europe/Rome" */
timeZone?: string;
localeMatcher?: "best fit" | "lookup";
formatMatcher?: "best fit" | "basic";
}

interface ResolvedDateTimeFormatOptions {
Expand Down