Bug 1672548 - Add weekday skeleton to DateTimeFormat::FormatDateTime(). r=gregtatum

Differential Revision: https://phabricator.services.mozilla.com/D119545
This commit is contained in:
JMM 2021-07-09 19:54:56 +00:00
parent 87cba8f0f4
commit 22f3732905
3 changed files with 18 additions and 1 deletions

View File

@ -81,6 +81,12 @@ nsresult DateTimeFormat::FormatDateTime(
case Skeleton::yyyyMMMM:
skeleton.AssignASCII("yyyyMMMM");
break;
case Skeleton::E:
skeleton.AssignASCII("E");
break;
case Skeleton::EEEE:
skeleton.AssignASCII("EEEE");
break;
default:
MOZ_ASSERT_UNREACHABLE("Unhandled skeleton enum");
}

View File

@ -37,7 +37,8 @@ class DateTimeFormat {
enum class Style { Wide, Abbreviated };
enum class Skeleton { yyyyMM, yyyyMMMM };
// Weekday (E, EEEE) only used in Thunderbird.
enum class Skeleton { yyyyMM, yyyyMMMM, E, EEEE };
// performs a locale sensitive date formatting operation on the PRTime
// parameter

View File

@ -223,6 +223,16 @@ TEST(DateTimeFormat, DateFormatSelectorsForeign)
ASSERT_TRUE(NS_SUCCEEDED(rv));
ASSERT_STREQ("Januar 1970", NS_ConvertUTF16toUTF8(formattedTime).get());
rv = mozilla::DateTimeFormat::FormatDateTime(
&prExplodedTime, DateTimeFormat::Skeleton::E, formattedTime);
ASSERT_TRUE(NS_SUCCEEDED(rv));
ASSERT_STREQ("Do", NS_ConvertUTF16toUTF8(formattedTime).get());
rv = mozilla::DateTimeFormat::FormatDateTime(
&prExplodedTime, DateTimeFormat::Skeleton::EEEE, formattedTime);
ASSERT_TRUE(NS_SUCCEEDED(rv));
ASSERT_STREQ("Donnerstag", NS_ConvertUTF16toUTF8(formattedTime).get());
rv = mozilla::DateTimeFormat::GetCalendarSymbol(
mozilla::DateTimeFormat::Field::Month,
mozilla::DateTimeFormat::Style::Wide, &prExplodedTime, formattedTime);