Commit 277fea61 authored by Jonathan Freed's avatar Jonathan Freed Committed by Commit Bot

Fixing incorrect day of week in mhtml header.

Bug: 826799
Change-Id: Ibf6b452aee7256cbb45d7d214729529c09acb5ab
Reviewed-on: https://chromium-review.googlesource.com/1012186Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarJian Li <jianli@chromium.org>
Commit-Queue: Jonathan Freed <freedjm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#552919}
parent 053aac8c
......@@ -61,7 +61,7 @@ class MHTMLArchiveTest : public testing::Test {
MHTMLArchiveTest() {
file_path_ = test::CoreTestDataPath("frameserializer/css/");
mhtml_date_ = WTF::Time::FromJsTime(1520551829000);
mhtml_date_header_ = String::FromUTF8("Fri, 8 Mar 2018 23:30:29 -0000");
mhtml_date_header_ = String::FromUTF8("Thu, 8 Mar 2018 23:30:29 -0000");
}
protected:
......
......@@ -218,14 +218,7 @@ void MHTMLArchive::GenerateMHTMLHeader(const String& boundary,
DCHECK(!boundary.IsEmpty());
DCHECK(!mime_type.IsEmpty());
// TODO(lukasza): Passing individual date/time components seems fragile.
base::Time::Exploded date_components;
date.UTCExplode(&date_components);
String date_string = MakeRFC2822DateString(
date_components.day_of_week, date_components.day_of_month,
// |month| is 1-based in Exploded, but 0-based in MakeRFC2822DateString.
date_components.month - 1, date_components.year, date_components.hour,
date_components.minute, date_components.second, 0);
String date_string = MakeRFC2822DateString(date, 0);
StringBuilder string_builder;
string_builder.Append("From: <Saved by Blink>\r\n");
......
......@@ -804,29 +804,26 @@ double ParseDateFromNullTerminatedCharacters(const char* date_string) {
}
// See http://tools.ietf.org/html/rfc2822#section-3.3 for more information.
String MakeRFC2822DateString(unsigned day_of_week,
unsigned day,
unsigned month,
unsigned year,
unsigned hours,
unsigned minutes,
unsigned seconds,
int utc_offset) {
String MakeRFC2822DateString(const Time date, int utc_offset) {
Time::Exploded time_exploded;
date.UTCExplode(&time_exploded);
StringBuilder string_builder;
string_builder.Append(kWeekdayName[day_of_week]);
string_builder.Append(kWeekdayName[time_exploded.day_of_week]);
string_builder.Append(", ");
string_builder.AppendNumber(day);
string_builder.AppendNumber(time_exploded.day_of_month);
string_builder.Append(' ');
string_builder.Append(kMonthName[month]);
// |month| is 1-based in Exploded
string_builder.Append(kMonthName[time_exploded.month - 1]);
string_builder.Append(' ');
string_builder.AppendNumber(year);
string_builder.AppendNumber(time_exploded.year);
string_builder.Append(' ');
AppendTwoDigitNumber(string_builder, hours);
AppendTwoDigitNumber(string_builder, time_exploded.hour);
string_builder.Append(':');
AppendTwoDigitNumber(string_builder, minutes);
AppendTwoDigitNumber(string_builder, time_exploded.minute);
string_builder.Append(':');
AppendTwoDigitNumber(string_builder, seconds);
AppendTwoDigitNumber(string_builder, time_exploded.second);
string_builder.Append(' ');
string_builder.Append(utc_offset > 0 ? '+' : '-');
......
......@@ -46,6 +46,7 @@
#include <stdint.h>
#include <string.h>
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/time.h"
#include "third_party/blink/renderer/platform/wtf/wtf_export.h"
namespace WTF {
......@@ -56,25 +57,12 @@ WTF_EXPORT void InitializeDates();
// these.
WTF_EXPORT double ParseDateFromNullTerminatedCharacters(
const char* date_string);
// dayOfWeek: [0, 6] 0 being Monday
// day: [1, 31]
// month: [0, 11]
// year: ex: 2011
// hours: [0, 23]
// minutes: [0, 59]
// seconds: [0, 59]
// utcOffset: [-720,720].
WTF_EXPORT String MakeRFC2822DateString(unsigned day_of_week,
unsigned day,
unsigned month,
unsigned year,
unsigned hours,
unsigned minutes,
unsigned seconds,
int utc_offset);
WTF_EXPORT String MakeRFC2822DateString(const Time date, int utc_offset);
const char kWeekdayName[7][4] = {"Mon", "Tue", "Wed", "Thu",
"Fri", "Sat", "Sun"};
const char kWeekdayName[7][4] = {"Sun", "Mon", "Tue", "Wed",
"Thu", "Fri", "Sat"};
const char kMonthName[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
const char* const kMonthFullName[12] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment