Skip to content

Commit 55014fb

Browse files
committed
fix: fixes microsoft#35865 - document and flesh out legal Intl.DateTimeFormatOptions types
1 parent 45cf20c commit 55014fb

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/lib/es5.d.ts

+25-11
Original file line numberDiff line numberDiff line change
@@ -4277,20 +4277,34 @@ declare namespace Intl {
42774277
supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[];
42784278
};
42794279

4280+
type DateFormatNumericVerbosity = "numeric" | "2-digit";
4281+
type DateFormatNameVerbosity = "long" | "short" | "narrow";
4282+
42804283
interface DateTimeFormatOptions {
4281-
localeMatcher?: string;
4282-
weekday?: string;
4283-
era?: string;
4284-
year?: string;
4285-
month?: string;
4286-
day?: string;
4287-
hour?: string;
4288-
minute?: string;
4289-
second?: string;
4290-
timeZoneName?: string;
4291-
formatMatcher?: string;
4284+
/** output examples – numeric: "2020", 2-digit: "20" */
4285+
year?: DateFormatNumericVerbosity;
4286+
/** output examples – numeric: "3", 2-digit: "03", long: "March", short: "Mar", narrow: "M" */
4287+
month?: DateFormatNumericVerbosity | DateFormatNameVerbosity;
4288+
/** output examples – numeric: "2", 2-digit: "02" */
4289+
day?: DateFormatNumericVerbosity;
4290+
/** output examples – numeric: "2", 2-digit: "02" */
4291+
hour?: DateFormatNumericVerbosity;
4292+
/** output examples – numeric: "2", 2-digit: "02" */
4293+
minute?: DateFormatNumericVerbosity;
4294+
/** output examples – numeric: "2", 2-digit: "02" */
4295+
second?: DateFormatNumericVerbosity;
4296+
/** output examples – long: "Thursday", short: "Thu", narrow: "T" */
4297+
weekday?: DateFormatNameVerbosity;
4298+
/** output examples – long: "Anno Domini", short: "AD", narrow "A" */
4299+
era?: DateFormatNameVerbosity;
4300+
/** set to `true` to force 12-hour am/pm "dayPeriod" values, or `false` to force 24-hour time without */
42924301
hour12?: boolean;
4302+
/** output examples – long: "Pacific Daylight Time", short: "PDT" */
4303+
timeZoneName?: "long" | "short";
4304+
/** set to the timezone name you want to render date and time for, e g "UTC", "Europe/Rome" */
42934305
timeZone?: string;
4306+
localeMatcher?: "best fit" | "lookup";
4307+
formatMatcher?: "best fit" | "basic";
42944308
}
42954309

42964310
interface ResolvedDateTimeFormatOptions {

0 commit comments

Comments
 (0)