Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CHROME_COMMON_TIME_FORMAT_H__ | 5 #ifndef CHROME_COMMON_TIME_FORMAT_H_ |
| 6 #define CHROME_COMMON_TIME_FORMAT_H__ | 6 #define CHROME_COMMON_TIME_FORMAT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // This file defines methods to format time values as strings. | 9 #include "base/basictypes.h" |
| 10 | |
| 11 #include "base/string16.h" | 10 #include "base/string16.h" |
| 12 | 11 |
| 13 namespace base { | 12 namespace base { |
| 14 class Time; | 13 class Time; |
| 15 class TimeDelta; | 14 class TimeDelta; |
| 16 } | 15 } |
| 17 | 16 |
| 17 // This class defines methods to format time values as strings. | |
|
Paweł Hajdan Jr.
2011/10/18 09:59:35
nit: Omit "This class defines". Or maybe the whole
tfarina
2011/10/18 16:00:53
Yeah, that is what I had in mind for a follow up p
| |
| 18 class TimeFormat { | 18 class TimeFormat { |
| 19 public: | 19 public: |
| 20 // TimeElapsed, TimeRemaining and TimeRemainingShort functions: | 20 // TimeElapsed, TimeRemaining and TimeRemainingShort functions: |
| 21 // These functions return a localized string of approximate time duration. The | 21 // These functions return a localized string of approximate time duration. The |
| 22 // conditions are simpler than PastTime since these functions are used for | 22 // conditions are simpler than PastTime since these functions are used for |
| 23 // in-progress operations and users have different expectations of units. | 23 // in-progress operations and users have different expectations of units. |
| 24 | 24 |
| 25 // Returns times in elapsed-format: "3 mins ago", "2 days ago". | 25 // Returns times in elapsed-format: "3 mins ago", "2 days ago". |
| 26 static string16 TimeElapsed(const base::TimeDelta& delta); | 26 static string16 TimeElapsed(const base::TimeDelta& delta); |
| 27 | 27 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 39 // TODO(tc): This should be able to do things like "Last week". This | 39 // TODO(tc): This should be able to do things like "Last week". This |
| 40 // requires handling singluar/plural for all languages. | 40 // requires handling singluar/plural for all languages. |
| 41 // | 41 // |
| 42 // The second parameter is optional, it is midnight of "Now" for relative day | 42 // The second parameter is optional, it is midnight of "Now" for relative day |
| 43 // computations: Time::Now().LocalMidnight() | 43 // computations: Time::Now().LocalMidnight() |
| 44 // If NULL, the current day's midnight will be retrieved, which can be | 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 | 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. | 46 // time once at the beginning and pass it for each computation. |
| 47 static string16 RelativeDate(const base::Time& time, | 47 static string16 RelativeDate(const base::Time& time, |
| 48 const base::Time* optional_midnight_today); | 48 const base::Time* optional_midnight_today); |
| 49 | |
| 50 private: | |
| 51 DISALLOW_IMPLICIT_CONSTRUCTORS(TimeFormat); | |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 #endif // CHROME_COMMON_TIME_FORMAT_H__ | 54 #endif // CHROME_COMMON_TIME_FORMAT_H_ |
| OLD | NEW |