зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1669573 - Rename kTimeFormatSeconds and kTimeFormatNoSeconds; r=zbraniecki
This renames kTimeFormatSeconds to kTimeFormatLong and kTimeFormatNoSeconds to kTimeFormatShort. This is consistent with the naming used for date format selectors. Differential Revision: https://phabricator.services.mozilla.com/D93011
This commit is contained in:
Родитель
9cd711db66
Коммит
c7c8e3f274
|
@ -249,14 +249,14 @@ nsresult DateTimeFormat::FormatUDateTime(
|
|||
// Get the time style for the formatter.
|
||||
nsAutoString patternTime;
|
||||
switch (aTimeFormatSelector) {
|
||||
case kTimeFormatSeconds:
|
||||
case kTimeFormatLong:
|
||||
rv = OSPreferences::GetInstance()->GetDateTimePattern(
|
||||
mozIOSPreferences::dateTimeFormatStyleNone,
|
||||
mozIOSPreferences::dateTimeFormatStyleLong,
|
||||
nsDependentCString(mLocale->get()), patternTime);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
break;
|
||||
case kTimeFormatNoSeconds:
|
||||
case kTimeFormatShort:
|
||||
rv = OSPreferences::GetInstance()->GetDateTimePattern(
|
||||
mozIOSPreferences::dateTimeFormatStyleNone,
|
||||
mozIOSPreferences::dateTimeFormatStyleShort,
|
||||
|
|
|
@ -27,9 +27,9 @@ enum nsDateFormatSelector : long {
|
|||
|
||||
enum nsTimeFormatSelector : long {
|
||||
kTimeFormatNone = 0, // don't include the time in the format string
|
||||
kTimeFormatSeconds, // provides the time format with seconds in the given
|
||||
kTimeFormatLong, // provides the time format with seconds in the given
|
||||
// locale
|
||||
kTimeFormatNoSeconds // provides the time format without seconds in the given
|
||||
kTimeFormatShort // provides the time format without seconds in the given
|
||||
// locale
|
||||
};
|
||||
|
||||
|
|
|
@ -36,14 +36,14 @@ TEST(DateTimeFormat, FormatPRExplodedTime)
|
|||
|
||||
nsAutoString formattedTime;
|
||||
nsresult rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("January 1, 1970, 12:00:00 AM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
||||
prExplodedTime = {0, 0, 19, 0, 1, 0, 1970, 4, 0, {(19 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("January 1, 1970, 12:19:00 AM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -51,7 +51,7 @@ TEST(DateTimeFormat, FormatPRExplodedTime)
|
|||
prExplodedTime = {0, 0, 0, 7, 1,
|
||||
0, 1970, 4, 0, {(6 * 60 * 60), (1 * 60 * 60)}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("January 1, 1970, 7:00:00 AM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -60,21 +60,21 @@ TEST(DateTimeFormat, FormatPRExplodedTime)
|
|||
0, 0, 29, 11, 1,
|
||||
0, 1970, 4, 0, {(10 * 60 * 60) + (29 * 60), (1 * 60 * 60)}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("January 1, 1970, 11:29:00 AM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
||||
prExplodedTime = {0, 0, 37, 23, 31, 11, 1969, 3, 364, {-(23 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("December 31, 1969, 11:37:00 PM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
||||
prExplodedTime = {0, 0, 0, 17, 31, 11, 1969, 3, 364, {-(7 * 60 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("December 31, 1969, 5:00:00 PM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -83,7 +83,7 @@ TEST(DateTimeFormat, FormatPRExplodedTime)
|
|||
0, 0, 47, 14, 31,
|
||||
11, 1969, 3, 364, {-((10 * 60 * 60) + (13 * 60)), (1 * 60 * 60)}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("December 31, 1969, 2:47:00 PM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -117,14 +117,13 @@ TEST(DateTimeFormat, DateFormatSelectors)
|
|||
ASSERT_STREQ("January", NS_ConvertUTF16toUTF8(formattedTime).get());
|
||||
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatYearMonth, kTimeFormatNoSeconds, &prExplodedTime,
|
||||
formattedTime);
|
||||
kDateFormatYearMonth, kTimeFormatShort, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("01/1970, 12:00 AM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatYearMonth, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatYearMonth, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("01/1970, 12:00:00 AM",
|
||||
nt(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -165,14 +164,14 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
|
||||
nsAutoString formattedTime;
|
||||
nsresult rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("1. Januar 1970, 00:00:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
||||
prExplodedTime = {0, 0, 19, 0, 1, 0, 1970, 4, 0, {(19 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("1. Januar 1970, 00:19:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -180,7 +179,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
prExplodedTime = {0, 0, 0, 7, 1,
|
||||
0, 1970, 4, 0, {(6 * 60 * 60), (1 * 60 * 60)}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("1. Januar 1970, 07:00:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -189,21 +188,21 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
0, 0, 29, 11, 1,
|
||||
0, 1970, 4, 0, {(10 * 60 * 60) + (29 * 60), (1 * 60 * 60)}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("1. Januar 1970, 11:29:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
||||
prExplodedTime = {0, 0, 37, 23, 31, 11, 1969, 3, 364, {-(23 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("31. Dezember 1969, 23:37:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
||||
prExplodedTime = {0, 0, 0, 17, 31, 11, 1969, 3, 364, {-(7 * 60 * 60), 0}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("31. Dezember 1969, 17:00:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -212,7 +211,7 @@ TEST(DateTimeFormat, FormatPRExplodedTimeForeign)
|
|||
0, 0, 47, 14, 31,
|
||||
11, 1969, 3, 364, {-((10 * 60 * 60) + (13 * 60)), (1 * 60 * 60)}};
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatLong, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatLong, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("31. Dezember 1969, 14:47:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
@ -246,14 +245,13 @@ TEST(DateTimeFormat, DateFormatSelectorsForeign)
|
|||
ASSERT_STREQ("Januar", NS_ConvertUTF16toUTF8(formattedTime).get());
|
||||
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatYearMonth, kTimeFormatNoSeconds, &prExplodedTime,
|
||||
formattedTime);
|
||||
kDateFormatYearMonth, kTimeFormatShort, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("01.1970, 00:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
||||
rv = mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
kDateFormatYearMonth, kTimeFormatSeconds, &prExplodedTime, formattedTime);
|
||||
kDateFormatYearMonth, kTimeFormatLong, &prExplodedTime, formattedTime);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
ASSERT_STREQ("01.1970, 00:00:00",
|
||||
ntd(NS_ConvertUTF16toUTF8(formattedTime)).get());
|
||||
|
|
|
@ -376,7 +376,7 @@ void nsPageSequenceFrame::Reflow(nsPresContext* aPresContext,
|
|||
nsAutoString formattedDateString;
|
||||
PRTime now = PR_Now();
|
||||
if (NS_SUCCEEDED(DateTimeFormat::FormatPRTime(
|
||||
kDateFormatShort, kTimeFormatNoSeconds, now, formattedDateString))) {
|
||||
kDateFormatShort, kTimeFormatShort, now, formattedDateString))) {
|
||||
SetDateTimeStr(formattedDateString);
|
||||
}
|
||||
|
||||
|
|
|
@ -808,7 +808,7 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest* aRequest, nsISupports* aCtxt,
|
|||
FormatTime(kDateFormatShort, kTimeFormatNone, t, formatted);
|
||||
AppendNonAsciiToNCR(formatted, pushBuffer);
|
||||
pushBuffer.AppendLiteral("</td>\n <td>");
|
||||
FormatTime(kDateFormatNone, kTimeFormatSeconds, t, formatted);
|
||||
FormatTime(kDateFormatNone, kTimeFormatLong, t, formatted);
|
||||
// use NCR to show date in any doc charset
|
||||
AppendNonAsciiToNCR(formatted, pushBuffer);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ nsresult X509CertValidity::FormatTime(
|
|||
|
||||
NS_IMETHODIMP
|
||||
X509CertValidity::GetNotBeforeLocalTime(nsAString& aNotBeforeLocalTime) {
|
||||
return FormatTime(mNotBefore, PR_LocalTimeParameters, kTimeFormatSeconds,
|
||||
return FormatTime(mNotBefore, PR_LocalTimeParameters, kTimeFormatLong,
|
||||
aNotBeforeLocalTime);
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ X509CertValidity::GetNotBeforeLocalDay(nsAString& aNotBeforeLocalDay) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
X509CertValidity::GetNotBeforeGMT(nsAString& aNotBeforeGMT) {
|
||||
return FormatTime(mNotBefore, PR_GMTParameters, kTimeFormatSeconds,
|
||||
return FormatTime(mNotBefore, PR_GMTParameters, kTimeFormatLong,
|
||||
aNotBeforeGMT);
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ X509CertValidity::GetNotAfter(PRTime* aNotAfter) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
X509CertValidity::GetNotAfterLocalTime(nsAString& aNotAfterLocaltime) {
|
||||
return FormatTime(mNotAfter, PR_LocalTimeParameters, kTimeFormatSeconds,
|
||||
return FormatTime(mNotAfter, PR_LocalTimeParameters, kTimeFormatLong,
|
||||
aNotAfterLocaltime);
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,5 @@ X509CertValidity::GetNotAfterLocalDay(nsAString& aNotAfterLocalDay) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
X509CertValidity::GetNotAfterGMT(nsAString& aNotAfterGMT) {
|
||||
return FormatTime(mNotAfter, PR_GMTParameters, kTimeFormatSeconds,
|
||||
aNotAfterGMT);
|
||||
return FormatTime(mNotAfter, PR_GMTParameters, kTimeFormatLong, aNotAfterGMT);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче