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

Side by Side Diff: chrome/common/time_format.cc

Issue 10918274: chrome://downloads updateDateDisplay more often (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/time_format.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/time_format.h" 5 #include "chrome/common/time_format.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 string16 TimeFormat::TimeRemainingShort(const TimeDelta& delta) { 318 string16 TimeFormat::TimeRemainingShort(const TimeDelta& delta) {
319 return FormatTimeImpl(delta, FORMAT_SHORT); 319 return FormatTimeImpl(delta, FORMAT_SHORT);
320 } 320 }
321 321
322 // static 322 // static
323 string16 TimeFormat::RelativeDate( 323 string16 TimeFormat::RelativeDate(
324 const Time& time, 324 const Time& time,
325 const Time* optional_midnight_today) { 325 const Time* optional_midnight_today) {
326 Time midnight_today = optional_midnight_today ? *optional_midnight_today : 326 Time midnight_today = optional_midnight_today ? *optional_midnight_today :
327 Time::Now().LocalMidnight(); 327 Time::Now().LocalMidnight();
328 328 TimeDelta day = TimeDelta::FromMicroseconds(Time::kMicrosecondsPerDay);
329 // Filter out "today" and "yesterday" 329 Time tomorrow = midnight_today + day;
330 if (time >= midnight_today) 330 Time yesterday = midnight_today - day;
331 if (time >= tomorrow)
332 return string16();
333 else if (time >= midnight_today)
331 return l10n_util::GetStringUTF16(IDS_PAST_TIME_TODAY); 334 return l10n_util::GetStringUTF16(IDS_PAST_TIME_TODAY);
332 else if (time >= midnight_today - 335 else if (time >= yesterday)
333 TimeDelta::FromMicroseconds(Time::kMicrosecondsPerDay))
334 return l10n_util::GetStringUTF16(IDS_PAST_TIME_YESTERDAY); 336 return l10n_util::GetStringUTF16(IDS_PAST_TIME_YESTERDAY);
335
336 return string16(); 337 return string16();
337 } 338 }
OLDNEW
« no previous file with comments | « chrome/common/time_format.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698