Skip to content
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

[release/8.0][browser] Fix failures in CalendarTestBase affecting several globalization tests #99407

Merged
merged 3 commits into from
Mar 8, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,11 @@ public static IEnumerable<object[]> AbbreviatedMonthGenitiveNames_Get_TestData_H
yield return new object[] { new CultureInfo("ms-BN").DateTimeFormat, new string[] { "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis", "" } };
yield return new object[] { new CultureInfo("ms-MY").DateTimeFormat, new string[] { "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis", "" } };
yield return new object[] { new CultureInfo("ms-SG").DateTimeFormat, new string[] { "Jan", "Feb", "Mac", "Apr", "Mei", "Jun", "Jul", "Ogo", "Sep", "Okt", "Nov", "Dis", "" } };
yield return new object[] { new CultureInfo("nb-NO").DateTimeFormat, new string[] { "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des.", "" } };
yield return new object[] { new CultureInfo("no-NO").DateTimeFormat, new string[] { "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des.", "" } };
string[] norwegianMonths = PlatformDetection.IsBrowserDomSupported ? // dotnet responds like non-browser
new string [] { "jan.", "feb.", "mar.", "apr.", "mai", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "des.", "" } :
new string [] { "jan.", "feb.", "mars", "apr.", "mai", "juni", "juli", "aug.", "sep.", "okt.", "nov.", "des.", "" };
yield return new object[] { new CultureInfo("nb-NO").DateTimeFormat, norwegianMonths };
yield return new object[] { new CultureInfo("no-NO").DateTimeFormat, norwegianMonths };
string[] dutchMonths = PlatformDetection.IsNodeJS ? // NodeJs responds like dotnet
new string[] { "jan.", "feb.", "mrt.", "apr.", "mei", "jun.", "jul.", "aug.", "sep.", "okt.", "nov.", "dec.", "" } :
new string[] { "jan", "feb", "mrt", "apr", "mei", "jun", "jul", "aug", "sep", "okt", "nov", "dec", "" };
Expand Down
13 changes: 10 additions & 3 deletions src/mono/wasm/runtime/hybrid-globalization/culture-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function mono_wasm_get_culture_info(culture: MonoStringRef, dst: number,

function getAmPmDesignators(locale: any)
{
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
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
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
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
const pmDesignator = getDesignator(pmTime, locale);
const amDesignator = getDesignator(amTime, locale);
return {
Expand All @@ -59,7 +59,14 @@ function getAmPmDesignators(locale: any)

function getDesignator(time: Date, locale: string)
{
const withDesignator = time.toLocaleTimeString(locale, { hourCycle: "h12"});
let withDesignator = time.toLocaleTimeString(locale, { hourCycle: "h12"});
const localizedZero = (0).toLocaleString(locale);
if (withDesignator.includes(localizedZero))
{
// in v8>=11.8 "12" changes to "0" for ja-JP
const localizedTwelve = (12).toLocaleString(locale);
withDesignator = withDesignator.replace(localizedZero, localizedTwelve);
}
const withoutDesignator = time.toLocaleTimeString(locale, { hourCycle: "h24"});
const designator = withDesignator.replace(withoutDesignator, "").trim();
if (new RegExp("[0-9]$").test(designator)){
Expand Down
Loading