зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1560574 - use FormatPRExplodedTime to display GMT; r=kershaw
Differential Revision: https://phabricator.services.mozilla.com/D36502 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6c32e4cdbf
Коммит
8b0df5b122
|
@ -294,7 +294,7 @@ char* nsFTPDirListingConv::DigestBufferLines(char* aBuffer,
|
|||
// the application/http-index-format specs
|
||||
// viewers of such a format can then reformat this into the
|
||||
// current locale (or anything else they choose)
|
||||
PR_FormatTimeUSEnglish(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S",
|
||||
PR_FormatTimeUSEnglish(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S GMT",
|
||||
&result.fe_time);
|
||||
|
||||
nsAutoCString escaped;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsDirIndexParser.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include <algorithm>
|
||||
#include "nsIChannel.h"
|
||||
#include "mozilla/Unused.h"
|
||||
|
@ -653,6 +654,24 @@ nsIndexedToHTML::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aInput,
|
|||
return mParser->OnDataAvailable(aRequest, aInput, aOffset, aCount);
|
||||
}
|
||||
|
||||
static nsresult FormatTime(const nsDateFormatSelector aDateFormatSelector,
|
||||
const nsTimeFormatSelector aTimeFormatSelector,
|
||||
const PRTime aPrTime, nsAString& aStringOut) {
|
||||
// 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::DateTimeFormat::FormatPRTime(
|
||||
aDateFormatSelector, aTimeFormatSelector, aPrTime, aStringOut);
|
||||
}
|
||||
|
||||
PRExplodedTime prExplodedTime;
|
||||
PR_ExplodeTime(aPrTime, PR_GMTParameters, &prExplodedTime);
|
||||
return mozilla::DateTimeFormat::FormatPRExplodedTime(
|
||||
aDateFormatSelector, aTimeFormatSelector, &prExplodedTime, aStringOut);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIndexedToHTML::OnIndexAvailable(nsIRequest* aRequest, nsISupports* aCtxt,
|
||||
nsIDirIndex* aIndex) {
|
||||
|
@ -799,12 +818,10 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest* aRequest, nsISupports* aCtxt,
|
|||
pushBuffer.AppendInt(static_cast<int64_t>(t));
|
||||
pushBuffer.AppendLiteral("\">");
|
||||
nsAutoString formatted;
|
||||
mozilla::DateTimeFormat::FormatPRTime(kDateFormatShort, kTimeFormatNone, t,
|
||||
formatted);
|
||||
FormatTime(kDateFormatShort, kTimeFormatNone, t, formatted);
|
||||
AppendNonAsciiToNCR(formatted, pushBuffer);
|
||||
pushBuffer.AppendLiteral("</td>\n <td>");
|
||||
mozilla::DateTimeFormat::FormatPRTime(kDateFormatNone, kTimeFormatSeconds,
|
||||
t, formatted);
|
||||
FormatTime(kDateFormatNone, kTimeFormatSeconds, t, formatted);
|
||||
// use NCR to show date in any doc charset
|
||||
AppendNonAsciiToNCR(formatted, pushBuffer);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "a%20" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n',
|
||||
'201: "a%20" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT DIRECTORY \n',
|
||||
],
|
||||
[
|
||||
/* Unix style listing, space at the end of link name */
|
||||
|
@ -17,7 +17,7 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "l%20" 2 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n',
|
||||
'201: "l%20" 2 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT SYMBOLIC-LINK \n',
|
||||
],
|
||||
[
|
||||
/* Unix style listing, regular file with " -> " in name */
|
||||
|
@ -26,7 +26,7 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "arrow%20-%3E%20in%20name%20" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n',
|
||||
'201: "arrow%20-%3E%20in%20name%20" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
[
|
||||
/* Unix style listing, tab at the end of filename */
|
||||
|
@ -35,7 +35,7 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "t%09" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 DIRECTORY \n',
|
||||
'201: "t%09" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT DIRECTORY \n',
|
||||
],
|
||||
[
|
||||
/* Unix style listing, multiple " -> " in filename */
|
||||
|
@ -44,7 +44,7 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "symlink%20with%20arrow%20-%3E%20in%20name" 26 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n',
|
||||
'201: "symlink%20with%20arrow%20-%3E%20in%20name" 26 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT SYMBOLIC-LINK \n',
|
||||
],
|
||||
[
|
||||
/* Unix style listing, multiple " -> " in filename, incorrect filesize */
|
||||
|
@ -53,7 +53,7 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "symlink%20with%20arrow%20-%3E%20in%20name%20-%3E%20file%20with%20arrow" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 SYMBOLIC-LINK \n',
|
||||
'201: "symlink%20with%20arrow%20-%3E%20in%20name%20-%3E%20file%20with%20arrow" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT SYMBOLIC-LINK \n',
|
||||
],
|
||||
[
|
||||
/* DOS style listing, space at the end of filename, year 1999 */
|
||||
|
@ -62,7 +62,7 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "file%20" 1024 Fri%2C%2001%20Jan%201999%2001%3A00%3A00 FILE \n',
|
||||
'201: "file%20" 1024 Fri%2C%2001%20Jan%201999%2001%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
[
|
||||
/* DOS style listing, tab at the end of filename, year 2000 */
|
||||
|
@ -71,7 +71,7 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "file%09" 1024 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n',
|
||||
'201: "file%09" 1024 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "file1" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n' +
|
||||
'201: "%20file2" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n',
|
||||
'201: "file1" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n' +
|
||||
'201: "%20file2" 0 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
// old Hellsoft unix format
|
||||
[
|
||||
|
@ -22,8 +22,8 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "file1" 214059 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n' +
|
||||
'201: "file2" 214059 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n',
|
||||
'201: "file1" 214059 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n' +
|
||||
'201: "file2" 214059 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
// new Hellsoft unix format
|
||||
[
|
||||
|
@ -34,8 +34,8 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "file1" 192 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n' +
|
||||
'201: "%20file2" 192 Sat%2C%2001%20Jan%202000%2000%3A00%3A00 FILE \n',
|
||||
'201: "file1" 192 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n' +
|
||||
'201: "%20file2" 192 Sat%2C%2001%20Jan%202000%2000%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
// DOS format with correct offsets
|
||||
[
|
||||
|
@ -50,12 +50,12 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "dir1" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
|
||||
'201: "junction1" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
|
||||
'201: "file1" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n' +
|
||||
'201: "%20dir2" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
|
||||
'201: "%20junction2" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
|
||||
'201: "%20file2" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n',
|
||||
'201: "dir1" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
|
||||
'201: "junction1" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
|
||||
'201: "file1" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n' +
|
||||
'201: "%20dir2" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
|
||||
'201: "%20junction2" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
|
||||
'201: "%20file2" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
// DOS format with wrong offsets
|
||||
[
|
||||
|
@ -72,14 +72,14 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "dir1" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
|
||||
'201: "dir2" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
|
||||
'201: "dir3" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 DIRECTORY \n' +
|
||||
'201: "junction1" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
|
||||
'201: "junction2" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
|
||||
'201: "junction3" Sat%2C%2001%20Jan%202000%2001%3A00%3A00 SYMBOLIC-LINK \n' +
|
||||
'201: "file1" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n' +
|
||||
'201: "file2" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00 FILE \n',
|
||||
'201: "dir1" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
|
||||
'201: "dir2" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
|
||||
'201: "dir3" 0 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT DIRECTORY \n' +
|
||||
'201: "junction1" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
|
||||
'201: "junction2" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
|
||||
'201: "junction3" Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT SYMBOLIC-LINK \n' +
|
||||
'201: "file1" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n' +
|
||||
'201: "file2" 95077 Sat%2C%2001%20Jan%202000%2001%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ const tests = [
|
|||
URL +
|
||||
"\n" +
|
||||
"200: filename content-length last-modified file-type\n" +
|
||||
'201: "A" 2048 Wed%2C%2003%20Mar%201993%2018%3A09%3A01 FILE \n' +
|
||||
'201: "E" 2048 Mon%2C%2008%20Mar%201993%2018%3A09%3A01 FILE \n',
|
||||
'201: "A" 2048 Wed%2C%2003%20Mar%201993%2018%3A09%3A01%20GMT FILE \n' +
|
||||
'201: "E" 2048 Mon%2C%2008%20Mar%201993%2018%3A09%3A01%20GMT FILE \n',
|
||||
],
|
||||
[
|
||||
"\r\r\r\n",
|
||||
|
|
|
@ -22,24 +22,24 @@ const tests = [
|
|||
day +
|
||||
"%2C%2001%20Jan%20" +
|
||||
year +
|
||||
"%2020%3A19%3A00 FILE \n" +
|
||||
"%2020%3A19%3A00%20GMT FILE \n" +
|
||||
'201: "%20test.blankfile" 22 ' +
|
||||
day +
|
||||
"%2C%2001%20Jan%20" +
|
||||
year +
|
||||
"%2020%3A19%3A00 FILE \n" +
|
||||
'201: "%20test2.blankfile" 33 Tue%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n' +
|
||||
"%2020%3A19%3A00%20GMT FILE \n" +
|
||||
'201: "%20test2.blankfile" 33 Tue%2C%2001%20Apr%202008%2000%3A00%3A00%20GMT FILE \n' +
|
||||
'201: "nodup.file" 44 ' +
|
||||
day +
|
||||
"%2C%2001%20Jan%20" +
|
||||
year +
|
||||
"%2020%3A19%3A00 FILE \n" +
|
||||
"%2020%3A19%3A00%20GMT FILE \n" +
|
||||
'201: "test.file" 55 ' +
|
||||
day +
|
||||
"%2C%2001%20Jan%20" +
|
||||
year +
|
||||
"%2020%3A19%3A00 FILE \n" +
|
||||
'201: "test2.file" 66 Tue%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n',
|
||||
"%2020%3A19%3A00%20GMT FILE \n" +
|
||||
'201: "test2.file" 66 Tue%2C%2001%20Apr%202008%2000%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
|
||||
// standard ls format
|
||||
|
@ -59,24 +59,24 @@ const tests = [
|
|||
day +
|
||||
"%2C%2001%20Jan%20" +
|
||||
year +
|
||||
"%2020%3A19%3A00 FILE \n" +
|
||||
"%2020%3A19%3A00%20GMT FILE \n" +
|
||||
'201: "%20test.blankfile" 22 ' +
|
||||
day +
|
||||
"%2C%2001%20Jan%20" +
|
||||
year +
|
||||
"%2020%3A19%3A00 FILE \n" +
|
||||
'201: "%20test2.blankfile" 33 Tue%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n' +
|
||||
"%2020%3A19%3A00%20GMT FILE \n" +
|
||||
'201: "%20test2.blankfile" 33 Tue%2C%2001%20Apr%202008%2000%3A00%3A00%20GMT FILE \n' +
|
||||
'201: "nodup.file" 44 ' +
|
||||
day +
|
||||
"%2C%2001%20Jan%20" +
|
||||
year +
|
||||
"%2020%3A19%3A00 FILE \n" +
|
||||
"%2020%3A19%3A00%20GMT FILE \n" +
|
||||
'201: "test.file" 55 ' +
|
||||
day +
|
||||
"%2C%2001%20Jan%20" +
|
||||
year +
|
||||
"%2020%3A19%3A00 FILE \n" +
|
||||
'201: "test2.file" 66 Tue%2C%2001%20Apr%202008%2000%3A00%3A00 FILE \n',
|
||||
"%2020%3A19%3A00%20GMT FILE \n" +
|
||||
'201: "test2.file" 66 Tue%2C%2001%20Apr%202008%2000%3A00%3A00%20GMT FILE \n',
|
||||
],
|
||||
];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче