Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Unified Diff: Source/core/dom/Document.cpp

Issue 394903004: document.lastModified should consider user's local time zone (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index eba7ecdfb87d0d206d3d79923ba3816eb5daec3d..22726422d40f4248084186ae665b4be1e49e48f5 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -195,6 +195,7 @@
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/Platform.h"
#include "wtf/CurrentTime.h"
+#include "wtf/DateMath.h"
#include "wtf/HashFunctions.h"
#include "wtf/MainThread.h"
#include "wtf/StdLibExtras.h"
@@ -4069,6 +4070,13 @@ void Document::setDomain(const String& newDomain, ExceptionState& exceptionState
m_frame->script().updateSecurityOrigin(securityOrigin());
}
+static double convertToLocalTime(double ms)
tkent 2014/07/18 14:16:56 We have this calculation at multiple places. https
kangil_ 2014/07/21 02:34:42 Done.
+{
+ double utcOffset = calculateUTCOffset();
+ double dstOffset = calculateDSTOffset(ms, utcOffset);
+ return (ms + utcOffset + dstOffset);
+}
+
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified
String Document::lastModified() const
{
@@ -4078,7 +4086,7 @@ String Document::lastModified() const
if (DocumentLoader* documentLoader = loader()) {
const AtomicString& httpLastModified = documentLoader->response().httpHeaderField("Last-Modified");
if (!httpLastModified.isEmpty()) {
- date.setMillisecondsSinceEpochForDateTime(parseDate(httpLastModified));
+ date.setMillisecondsSinceEpochForDateTime(convertToLocalTime(parseDate(httpLastModified)));
foundDate = true;
}
}
@@ -4087,7 +4095,7 @@ String Document::lastModified() const
// specificiation tells us to read the last modification date from the file
// system.
if (!foundDate)
- date.setMillisecondsSinceEpochForDateTime(currentTimeMS());
+ date.setMillisecondsSinceEpochForDateTime(convertToLocalTime(currentTimeMS()));
return String::format("%02d/%02d/%04d %02d:%02d:%02d", date.month() + 1, date.monthDay(), date.fullYear(), date.hour(), date.minute(), date.second());
}

Powered by Google App Engine
This is Rietveld 408576698