| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 7 |
| 8 // This file defines methods to format time values as strings. | 8 // This file defines methods to format time values as strings. |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "unicode/smpdtfmt.h" | 12 #include "unicode/smpdtfmt.h" |
| 13 | 13 |
| 14 namespace base { |
| 14 class Time; | 15 class Time; |
| 15 class TimeDelta; | 16 class TimeDelta; |
| 17 } |
| 16 | 18 |
| 17 class TimeFormat { | 19 class TimeFormat { |
| 18 public: | 20 public: |
| 19 // Returns a localized string of approximate time remaining. The conditions | 21 // Returns a localized string of approximate time remaining. The conditions |
| 20 // are simpler than PastTime since this is used for in-progress operations | 22 // are simpler than PastTime since this is used for in-progress operations |
| 21 // and users have different expectations of units. | 23 // and users have different expectations of units. |
| 22 // Ex: "3 mins left", "2 days left". | 24 // Ex: "3 mins left", "2 days left". |
| 23 static std::wstring TimeRemaining(const TimeDelta& delta); | 25 static std::wstring TimeRemaining(const base::TimeDelta& delta); |
| 24 | 26 |
| 25 // Same as TimeRemaining without the "left". | 27 // Same as TimeRemaining without the "left". |
| 26 static std::wstring TimeRemainingShort(const TimeDelta& delta); | 28 static std::wstring TimeRemainingShort(const base::TimeDelta& delta); |
| 27 | 29 |
| 28 // For displaying a relative time in the past. This method returns either | 30 // For displaying a relative time in the past. This method returns either |
| 29 // "Today", "Yesterday", or an empty string if it's older than that. | 31 // "Today", "Yesterday", or an empty string if it's older than that. |
| 30 // | 32 // |
| 31 // TODO(brettw): This should be able to handle days in the future like | 33 // TODO(brettw): This should be able to handle days in the future like |
| 32 // "Tomorrow". | 34 // "Tomorrow". |
| 33 // TODO(tc): This should be able to do things like "Last week". This | 35 // TODO(tc): This should be able to do things like "Last week". This |
| 34 // requires handling singluar/plural for all languages. | 36 // requires handling singluar/plural for all languages. |
| 35 // | 37 // |
| 36 // The second parameter is optional, it is midnight of "Now" for relative day | 38 // The second parameter is optional, it is midnight of "Now" for relative day |
| 37 // computations: Time::Now().LocalMidnight() | 39 // computations: Time::Now().LocalMidnight() |
| 38 // If NULL, the current day's midnight will be retrieved, which can be | 40 // If NULL, the current day's midnight will be retrieved, which can be |
| 39 // slow. If many items are being processed, it is best to get the current | 41 // slow. If many items are being processed, it is best to get the current |
| 40 // time once at the beginning and pass it for each computation. | 42 // time once at the beginning and pass it for each computation. |
| 41 static std::wstring RelativeDate(const Time& time, | 43 static std::wstring RelativeDate(const base::Time& time, |
| 42 const Time* optional_midnight_today); | 44 const base::Time* optional_midnight_today); |
| 43 }; | 45 }; |
| 44 | 46 |
| 45 #endif // CHROME_COMMON_TIME_FORMAT_H__ | 47 #endif // CHROME_COMMON_TIME_FORMAT_H__ |
| 46 | |
| OLD | NEW |