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

Unified Diff: chrome/browser/bookmarks/bookmark_codec.cc

Issue 173296: Convert internal time format to Windows 1601 epoch on Linux & Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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
« no previous file with comments | « base/time_unittest.cc ('k') | chrome/browser/history/history_backend.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/bookmarks/bookmark_codec.cc
===================================================================
--- chrome/browser/bookmarks/bookmark_codec.cc (revision 24094)
+++ chrome/browser/bookmarks/bookmark_codec.cc (working copy)
@@ -200,6 +200,18 @@
std::wstring date_added_string;
if (!value.GetString(kDateAddedKey, &date_added_string))
date_added_string = Int64ToWString(Time::Now().ToInternalValue());
+ base::Time date_added = base::Time::FromInternalValue(
+ StringToInt64(WideToUTF16Hack(date_added_string)));
+#if !defined(OS_WIN)
+ // We changed the epoch for dates on Mac & Linux from 1970 to the Windows
+ // one of 1601. We assume any number we encounter from before 1970 is using
+ // the old format, so we need to add the delta to it.
+ if (date_added.ToInternalValue() <
+ base::Time::kWindowsEpochDeltaMicroseconds) {
+ date_added = base::Time::FromInternalValue(date_added.ToInternalValue() +
+ base::Time::kWindowsEpochDeltaMicroseconds);
+ }
+#endif
std::wstring type_string;
if (!value.GetString(kTypeKey, &type_string))
@@ -255,8 +267,7 @@
}
node->SetTitle(title);
- node->set_date_added(Time::FromInternalValue(
- StringToInt64(WideToUTF16Hack(date_added_string))));
+ node->set_date_added(date_added);
return true;
}
« no previous file with comments | « base/time_unittest.cc ('k') | chrome/browser/history/history_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698