| 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 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // Returns times in elapsed-format: "3 mins ago", "2 days ago". | 24 // Returns times in elapsed-format: "3 mins ago", "2 days ago". |
| 25 static string16 TimeElapsed(const base::TimeDelta& delta); | 25 static string16 TimeElapsed(const base::TimeDelta& delta); |
| 26 | 26 |
| 27 // Returns times in remaining-format: "3 mins left", "2 days left". | 27 // Returns times in remaining-format: "3 mins left", "2 days left". |
| 28 static string16 TimeRemaining(const base::TimeDelta& delta); | 28 static string16 TimeRemaining(const base::TimeDelta& delta); |
| 29 | 29 |
| 30 // Returns times in short-format: "3 mins", "2 days". | 30 // Returns times in short-format: "3 mins", "2 days". |
| 31 static string16 TimeRemainingShort(const base::TimeDelta& delta); | 31 static string16 TimeRemainingShort(const base::TimeDelta& delta); |
| 32 | 32 |
| 33 // For displaying a relative time in the past. This method returns either | 33 // For displaying a relative time in the past. This method returns either |
| 34 // "Today", "Yesterday", or an empty string if it's older than that. | 34 // "Today", "Yesterday", or an empty string if it's older than that. Returns |
| 35 // the empty string for days in the future. |
| 35 // | 36 // |
| 36 // TODO(brettw): This should be able to handle days in the future like | 37 // TODO(brettw): This should be able to handle days in the future like |
| 37 // "Tomorrow". | 38 // "Tomorrow". |
| 38 // 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 |
| 39 // requires handling singluar/plural for all languages. | 40 // requires handling singluar/plural for all languages. |
| 40 // | 41 // |
| 41 // 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 |
| 42 // computations: Time::Now().LocalMidnight() | 43 // computations: Time::Now().LocalMidnight() |
| 43 // 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 |
| 44 // 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 |
| 45 // time once at the beginning and pass it for each computation. | 46 // time once at the beginning and pass it for each computation. |
| 46 static string16 RelativeDate(const base::Time& time, | 47 static string16 RelativeDate(const base::Time& time, |
| 47 const base::Time* optional_midnight_today); | 48 const base::Time* optional_midnight_today); |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 DISALLOW_IMPLICIT_CONSTRUCTORS(TimeFormat); | 51 DISALLOW_IMPLICIT_CONSTRUCTORS(TimeFormat); |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 #endif // CHROME_COMMON_TIME_FORMAT_H_ | 54 #endif // CHROME_COMMON_TIME_FORMAT_H_ |
| OLD | NEW |