Skip to content
Merged
Changes from 1 commit
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
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