Skip to content

Commit a795118

Browse files
authored
🤖 Merge PR DefinitelyTyped#71910 Updated microsoft-ajax CultureInfo to match 4.5.2 implementation by @terryaney
1 parent bb29df9 commit a795118

File tree

3 files changed

+202
-13
lines changed

3 files changed

+202
-13
lines changed

‎types/microsoft-ajax/index.d.ts‎

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,75 @@ declare namespace Sys {
948948
// #endregion
949949
}
950950

951+
// Interfaces to match constructor of 4.5.2 implementation of Sys.CultureInfo
952+
// https://learn.microsoft.com/en-us/aspnet/ajax/cdn/cdnajax452
953+
interface DateTimeFormat {
954+
AMDesignator: string;
955+
Calendar: {
956+
MinSupportedDateTime: string; // Use string to represent dates in JSON
957+
MaxSupportedDateTime: string; // Use string to represent dates in JSON
958+
AlgorithmType: number;
959+
IsReadOnly: boolean;
960+
Eras: number[];
961+
TwoDigitYearMax: number;
962+
};
963+
DateSeparator: string;
964+
FirstDayOfWeek: number;
965+
CalendarWeekRule: number;
966+
FullDateTimePattern: string;
967+
LongDatePattern: string;
968+
LongTimePattern: string;
969+
MonthDayPattern: string;
970+
PMDesignator: string;
971+
RFC1123Pattern: string;
972+
ShortDatePattern: string;
973+
ShortTimePattern: string;
974+
SortableDateTimePattern: string;
975+
TimeSeparator: string;
976+
UniversalSortableDateTimePattern: string;
977+
YearMonthPattern: string;
978+
AbbreviatedDayNames: string[];
979+
ShortestDayNames: string[];
980+
DayNames: string[];
981+
AbbreviatedMonthNames: string[];
982+
MonthNames: string[];
983+
IsReadOnly: boolean;
984+
NativeCalendarName: string;
985+
AbbreviatedMonthGenitiveNames: string[];
986+
MonthGenitiveNames: string[];
987+
}
988+
989+
interface NumberFormat {
990+
CurrencyDecimalDigits: number;
991+
CurrencyDecimalSeparator: string;
992+
IsReadOnly: boolean;
993+
CurrencyGroupSizes: number[];
994+
NumberGroupSizes: number[];
995+
PercentGroupSizes: number[];
996+
CurrencyGroupSeparator: string;
997+
CurrencySymbol: string;
998+
NaNSymbol: string;
999+
CurrencyNegativePattern: number;
1000+
NumberNegativePattern: number;
1001+
PercentPositivePattern: number;
1002+
PercentNegativePattern: number;
1003+
NegativeInfinitySymbol: string;
1004+
NegativeSign: string;
1005+
NumberDecimalDigits: number;
1006+
NumberDecimalSeparator: string;
1007+
NumberGroupSeparator: string;
1008+
CurrencyPositivePattern: number;
1009+
PositiveInfinitySymbol: string;
1010+
PositiveSign: string;
1011+
PercentDecimalDigits: number;
1012+
PercentDecimalSeparator: string;
1013+
PercentGroupSeparator: string;
1014+
PercentSymbol: string;
1015+
PerMilleSymbol: string;
1016+
NativeDigits: string[];
1017+
DigitSubstitution: number;
1018+
}
1019+
9511020
/**
9521021
* Represents a culture definition that can be applied to objects that accept a culture-related setting.
9531022
* @see {@link http://msdn.microsoft.com/en-us/library/bb384004(v=vs.100).aspx}
@@ -960,23 +1029,23 @@ declare namespace Sys {
9601029
* @param name
9611030
* The culture value (locale) that represents a language and region.
9621031
* @param numberFormat
963-
* A culture-sensitive numeric formatting string.
1032+
* A culture-sensitive numeric formatting object.
9641033
* @param dateTimeFormat
965-
* A culture-sensitive date formatting string.
1034+
* A culture-sensitive date formatting object.
9661035
*/
967-
constructor(name: string, numberFormat: string, dateTimeFormat: string);
1036+
constructor(name: string, numberFormat: NumberFormat, dateTimeFormat: DateTimeFormat);
9681037

9691038
// #endregion
9701039

9711040
// #region Properties
9721041

9731042
/**
974-
* Gets an object that contains an array of culture-sensitive formatting and parsing strings values that can be applied to Number type extensions.
975-
* Use the numberFormat field to retrieve an object that contains an array of formatting strings that are based on the current culture or on the invariant culture.
1043+
* Gets an object that contains culture-sensitive formatting and parsing strings values that can be applied to Number type extensions.
1044+
* Use the numberFormat field to retrieve an object of formatting strings that are based on the current culture or on the invariant culture.
9761045
* Each formatting string can be used to specify how to format Number type extensions.
977-
* @return An object that contains an array of culture-sensitive formatting strings.
1046+
* @return An object of culture-sensitive formatting strings.
9781047
*/
979-
numberFormat: string[];
1048+
numberFormat: NumberFormat;
9801049
/**
9811050
* Gets the culture value (locale) that represents a language and region.
9821051
* @return The culture value (locale) that represents a language and region.
@@ -995,12 +1064,12 @@ declare namespace Sys {
9951064
*/
9961065
static CurrentCulture: CultureInfo;
9971066
/**
998-
* Gets an object that contains an array of culture-sensitive formatting and parsing string values that can be applied to Date type extensions.
999-
* Use the dateTimeFormat field to retrieve an object that contains an array of formatting strings that are based on the current culture or on the invariant culture.
1067+
* Gets an object that contains culture-sensitive formatting and parsing string values that can be applied to Date type extensions.
1068+
* Use the dateTimeFormat field to retrieve an object of formatting strings that are based on the current culture or on the invariant culture.
10001069
* Each formatting string can be used to specify how to format Date type extensions.
1001-
* @return An object that contains an array of culture-sensitive formatting strings.
1070+
* @return An object of culture-sensitive formatting strings.
10021071
*/
1003-
dateTimeFormat: string[];
1072+
dateTimeFormat: DateTimeFormat;
10041073

10051074
// #endregion
10061075
}

‎types/microsoft-ajax/microsoft-ajax-tests.ts‎

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,126 @@ function Sys_CultureInfo_Tests() {
451451
var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture;
452452
var dtfICObject = invariantCultureInfoObj.dateTimeFormat;
453453

454-
var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat");
454+
var newCulture = new Sys.CultureInfo("name", {
455+
"CurrencyDecimalDigits": 2,
456+
"CurrencyDecimalSeparator": ".",
457+
"IsReadOnly": true,
458+
"CurrencyGroupSizes": [3],
459+
"NumberGroupSizes": [3],
460+
"PercentGroupSizes": [3],
461+
"CurrencyGroupSeparator": ",",
462+
"CurrencySymbol": "$",
463+
"NaNSymbol": "NaN",
464+
"CurrencyNegativePattern": 0,
465+
"NumberNegativePattern": 1,
466+
"PercentPositivePattern": 1,
467+
"PercentNegativePattern": 1,
468+
"NegativeInfinitySymbol": "-∞",
469+
"NegativeSign": "-",
470+
"NumberDecimalDigits": 2,
471+
"NumberDecimalSeparator": ".",
472+
"NumberGroupSeparator": ",",
473+
"CurrencyPositivePattern": 0,
474+
"PositiveInfinitySymbol": "∞",
475+
"PositiveSign": "+",
476+
"PercentDecimalDigits": 2,
477+
"PercentDecimalSeparator": ".",
478+
"PercentGroupSeparator": ",",
479+
"PercentSymbol": "%",
480+
"PerMilleSymbol": "‰",
481+
"NativeDigits": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
482+
"DigitSubstitution": 1,
483+
}, {
484+
"AMDesignator": "AM",
485+
"Calendar": {
486+
"MinSupportedDateTime": "0001-01-01T00:00:00",
487+
"MaxSupportedDateTime": "9999-12-31T23:59:59.9999999",
488+
"AlgorithmType": 1,
489+
"IsReadOnly": true,
490+
"Eras": [1],
491+
"TwoDigitYearMax": 2029,
492+
},
493+
"DateSeparator": "/",
494+
"FirstDayOfWeek": 0,
495+
"CalendarWeekRule": 0,
496+
"FullDateTimePattern": "dddd, MMMM d, yyyy h:mm:ss tt",
497+
"LongDatePattern": "dddd, MMMM d, yyyy",
498+
"LongTimePattern": "h:mm:ss tt",
499+
"MonthDayPattern": "MMMM d",
500+
"PMDesignator": "PM",
501+
"RFC1123Pattern": "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'",
502+
"ShortDatePattern": "M/d/yyyy",
503+
"ShortTimePattern": "h:mm tt",
504+
"SortableDateTimePattern": "yyyy'-'MM'-'dd'T'HH':'mm':'ss",
505+
"TimeSeparator": ":",
506+
"UniversalSortableDateTimePattern": "yyyy'-'MM'-'dd HH':'mm':'ss'Z'",
507+
"YearMonthPattern": "MMMM yyyy",
508+
"AbbreviatedDayNames": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
509+
"ShortestDayNames": ["S", "M", "T", "W", "T", "F", "S"],
510+
"DayNames": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
511+
"AbbreviatedMonthNames": [
512+
"Jan",
513+
"Feb",
514+
"Mar",
515+
"Apr",
516+
"May",
517+
"Jun",
518+
"Jul",
519+
"Aug",
520+
"Sep",
521+
"Oct",
522+
"Nov",
523+
"Dec",
524+
"",
525+
],
526+
"MonthNames": [
527+
"January",
528+
"February",
529+
"March",
530+
"April",
531+
"May",
532+
"June",
533+
"July",
534+
"August",
535+
"September",
536+
"October",
537+
"November",
538+
"December",
539+
"",
540+
],
541+
"IsReadOnly": true,
542+
"NativeCalendarName": "Gregorian Calendar",
543+
"AbbreviatedMonthGenitiveNames": [
544+
"Jan",
545+
"Feb",
546+
"Mar",
547+
"Apr",
548+
"May",
549+
"Jun",
550+
"Jul",
551+
"Aug",
552+
"Sep",
553+
"Oct",
554+
"Nov",
555+
"Dec",
556+
"",
557+
],
558+
"MonthGenitiveNames": [
559+
"January",
560+
"February",
561+
"March",
562+
"April",
563+
"May",
564+
"June",
565+
"July",
566+
"August",
567+
"September",
568+
"October",
569+
"November",
570+
"December",
571+
"",
572+
],
573+
});
455574

456575
var format = newCulture.dateTimeFormat;
457576
var name = newCulture.name;

‎types/microsoft-ajax/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"private": true,
33
"name": "@types/microsoft-ajax",
4-
"version": "0.0.9999",
4+
"version": "4.5.9999",
55
"nonNpm": true,
66
"nonNpmDescription": "microsoft-ajax",
77
"projects": [
8+
"https://learn.microsoft.com/en-us/aspnet/ajax/cdn/cdnajax452",
89
"http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx"
910
],
1011
"devDependencies": {

0 commit comments

Comments
 (0)