Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 53e2082

Browse files
authored
[release/8.0][browser] Fix failures in CalendarTestBase affecting several globalization tests (#99407)
* Partial backport of #90881. * Backport updated expected test results. * Update should be only for v8. Browser/node were correct in the original form.
1 parent db167d9 commit 53e2082

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ public static IEnumerable<object[]> AbbreviatedMonthGenitiveNames_Get_TestData_H
170170
yield return new object[] { new CultureInfo("ms-BN").DateTimeFormat, new string[] { "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis", "" } };
171171
yield return new object[] { new CultureInfo("ms-MY").DateTimeFormat, new string[] { "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis", "" } };
172172
yield return new object[] { new CultureInfo("ms-SG").DateTimeFormat, new string[] { "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis", "" } };
173-
yield return new object[] { new CultureInfo("nb-NO").DateTimeFormat, new string[] { "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des.", "" } };
174-
yield return new object[] { new CultureInfo("no-NO").DateTimeFormat, new string[] { "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des.", "" } };
173+
string[] norwegianMonths = PlatformDetection.IsBrowserDomSupported ? // dotnet responds like non-browser
174+
new string [] { "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des.", "" } :
175+
new string [] { "jan.", "feb.", "mars", "apr.", "mai", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "des.", "" };
176+
yield return new object[] { new CultureInfo("nb-NO").DateTimeFormat, norwegianMonths };
177+
yield return new object[] { new CultureInfo("no-NO").DateTimeFormat, norwegianMonths };
175178
string[] dutchMonths = PlatformDetection.IsNodeJS ? // NodeJs responds like dotnet
176179
new string[] { "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec.", "" } :
177180
new string[] { "jan", "feb", "mrt", "apr", "mei", "jun", "jul", "aug", "sep", "okt", "nov", "dec", "" };

src/mono/wasm/runtime/hybrid-globalization/culture-info.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export function mono_wasm_get_culture_info(culture: MonoStringRef, dst: number,
4747

4848
function getAmPmDesignators(locale: any)
4949
{
50-
const pmTime = new Date("August 19, 1975 12:15:30"); // do not change, some PM hours result in hour digits change, e.g. 13 -> 01 or 1
51-
const amTime = new Date("August 19, 1975 11:15:30"); // do not change, some AM hours result in hour digits change, e.g. 9 -> 09
50+
const pmTime = new Date("August 19, 1975 12:15:33"); // do not change, some PM hours result in hour digits change, e.g. 13 -> 01 or 1
51+
const amTime = new Date("August 19, 1975 11:15:33"); // do not change, some AM hours result in hour digits change, e.g. 9 -> 09
5252
const pmDesignator = getDesignator(pmTime, locale);
5353
const amDesignator = getDesignator(amTime, locale);
5454
return {
@@ -59,7 +59,14 @@ function getAmPmDesignators(locale: any)
5959

6060
function getDesignator(time: Date, locale: string)
6161
{
62-
const withDesignator = time.toLocaleTimeString(locale, { hourCycle: "h12"});
62+
let withDesignator = time.toLocaleTimeString(locale, { hourCycle: "h12"});
63+
const localizedZero = (0).toLocaleString(locale);
64+
if (withDesignator.includes(localizedZero))
65+
{
66+
// in v8>=11.8 "12" changes to "0" for ja-JP
67+
const localizedTwelve = (12).toLocaleString(locale);
68+
withDesignator = withDesignator.replace(localizedZero, localizedTwelve);
69+
}
6370
const withoutDesignator = time.toLocaleTimeString(locale, { hourCycle: "h24"});
6471
const designator = withDesignator.replace(withoutDesignator, "").trim();
6572
if (new RegExp("[0-9]$").test(designator)){

0 commit comments

Comments
 (0)