Adding two local state prefs for component updater
[chromium-blink-merge.git] / chrome / common / time_format.h
blobd94ac14e30c0d436c5064349b9d39ec63cbab00c
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
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_TIME_FORMAT_H__
6 #define CHROME_COMMON_TIME_FORMAT_H__
7 #pragma once
9 // This file defines methods to format time values as strings.
11 #include "base/string16.h"
13 namespace base {
14 class Time;
15 class TimeDelta;
18 class TimeFormat {
19 public:
20 // TimeElapsed, TimeRemaining and TimeRemainingShort functions:
21 // These functions return a localized string of approximate time duration. The
22 // conditions are simpler than PastTime since these functions are used for
23 // in-progress operations and users have different expectations of units.
25 // Returns times in elapsed-format: "3 mins ago", "2 days ago".
26 static string16 TimeElapsed(const base::TimeDelta& delta);
28 // Returns times in remaining-format: "3 mins left", "2 days left".
29 static string16 TimeRemaining(const base::TimeDelta& delta);
31 // Returns times in short-format: "3 mins", "2 days".
32 static string16 TimeRemainingShort(const base::TimeDelta& delta);
34 // For displaying a relative time in the past. This method returns either
35 // "Today", "Yesterday", or an empty string if it's older than that.
37 // TODO(brettw): This should be able to handle days in the future like
38 // "Tomorrow".
39 // TODO(tc): This should be able to do things like "Last week". This
40 // requires handling singluar/plural for all languages.
42 // The second parameter is optional, it is midnight of "Now" for relative day
43 // computations: Time::Now().LocalMidnight()
44 // If NULL, the current day's midnight will be retrieved, which can be
45 // slow. If many items are being processed, it is best to get the current
46 // time once at the beginning and pass it for each computation.
47 static string16 RelativeDate(const base::Time& time,
48 const base::Time* optional_midnight_today);
51 #endif // CHROME_COMMON_TIME_FORMAT_H__