зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1752223 - Restore last modified time in directory listing. r=gregtatum,necko-reviewers,valentin
The directory listing code gets the last modified date and time in two separate goes, so we need to pass in the appropriate *date* style on the first go and the appropriate *time* style on the second go, just like the old code used to do. Differential Revision: https://phabricator.services.mozilla.com/D137075
This commit is contained in:
Родитель
34f4c14fff
Коммит
c012f02efb
|
@ -617,23 +617,21 @@ nsIndexedToHTML::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aInput,
|
|||
return mParser->OnDataAvailable(aRequest, aInput, aOffset, aCount);
|
||||
}
|
||||
|
||||
static nsresult FormatTime(const mozilla::intl::DateTimeFormat::Style& aStyle,
|
||||
static nsresult FormatTime(
|
||||
const mozilla::intl::DateTimeFormat::StyleBag& aStyleBag,
|
||||
const PRTime aPrTime, nsAString& aStringOut) {
|
||||
mozilla::intl::DateTimeFormat::StyleBag styleBag;
|
||||
styleBag.date = Some(aStyle);
|
||||
|
||||
// FormatPRExplodedTime will use GMT based formatted string (e.g. GMT+1)
|
||||
// instead of local time zone name (e.g. CEST).
|
||||
// To avoid this case when ResistFingerprinting is disabled, use
|
||||
// |FormatPRTime| to show exact time zone name.
|
||||
if (!nsContentUtils::ShouldResistFingerprinting()) {
|
||||
return mozilla::intl::AppDateTimeFormat::Format(styleBag, aPrTime,
|
||||
return mozilla::intl::AppDateTimeFormat::Format(aStyleBag, aPrTime,
|
||||
aStringOut);
|
||||
}
|
||||
|
||||
PRExplodedTime prExplodedTime;
|
||||
PR_ExplodeTime(aPrTime, PR_GMTParameters, &prExplodedTime);
|
||||
return mozilla::intl::AppDateTimeFormat::Format(styleBag, &prExplodedTime,
|
||||
return mozilla::intl::AppDateTimeFormat::Format(aStyleBag, &prExplodedTime,
|
||||
aStringOut);
|
||||
}
|
||||
|
||||
|
@ -782,11 +780,17 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest* aRequest, nsIDirIndex* aIndex) {
|
|||
pushBuffer.AppendLiteral(" sortable-data=\"");
|
||||
pushBuffer.AppendInt(static_cast<int64_t>(t));
|
||||
pushBuffer.AppendLiteral("\">");
|
||||
// Add date string
|
||||
nsAutoString formatted;
|
||||
FormatTime(mozilla::intl::DateTimeFormat::Style::Short, t, formatted);
|
||||
mozilla::intl::DateTimeFormat::StyleBag dateBag;
|
||||
dateBag.date = Some(mozilla::intl::DateTimeFormat::Style::Short);
|
||||
FormatTime(dateBag, t, formatted);
|
||||
AppendNonAsciiToNCR(formatted, pushBuffer);
|
||||
pushBuffer.AppendLiteral("</td>\n <td>");
|
||||
FormatTime(mozilla::intl::DateTimeFormat::Style::Long, t, formatted);
|
||||
// Add time string
|
||||
mozilla::intl::DateTimeFormat::StyleBag timeBag;
|
||||
timeBag.time = Some(mozilla::intl::DateTimeFormat::Style::Long);
|
||||
FormatTime(timeBag, t, formatted);
|
||||
// use NCR to show date in any doc charset
|
||||
AppendNonAsciiToNCR(formatted, pushBuffer);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче