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

Unified Diff: components/ntp_snippets/ntp_snippet.cc

Issue 2110393004: Parse snippet times properly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | components/ntp_snippets/ntp_snippet_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/ntp_snippet.cc
diff --git a/components/ntp_snippets/ntp_snippet.cc b/components/ntp_snippets/ntp_snippet.cc
index 125ec5199b2b1af20af0e86179699b262bc62455..640aea1e390994ec13896c5a6f6880368953bec5 100644
--- a/components/ntp_snippets/ntp_snippet.cc
+++ b/components/ntp_snippets/ntp_snippet.cc
@@ -19,16 +19,9 @@ namespace {
bool GetTimeValue(const base::DictionaryValue& dict,
const std::string& key,
base::Time* time) {
- const base::DictionaryValue* time_value;
- int seconds = 0, nanos = 0;
- if (!(dict.GetDictionary(key, &time_value) &&
- time_value->GetInteger("seconds", &seconds) &&
- time_value->GetInteger("nanos", &nanos))) {
- return false;
- }
- *time = base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(seconds) +
- base::TimeDelta::FromMicroseconds(nanos / 1000); // No nano support.
- return true;
+ std::string time_value;
+ return dict.GetString(key, &time_value) &&
+ base::Time::FromString(time_value.c_str(), time);
}
// dict.Get() specialization for GURL values
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippet_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698