| 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 UI_BASE_L10N_TIME_FORMAT_H_ | 5 #ifndef UI_BASE_L10N_TIME_FORMAT_H_ |
| 6 #define UI_BASE_L10N_TIME_FORMAT_H_ | 6 #define UI_BASE_L10N_TIME_FORMAT_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "ui/base/ui_base_export.h" | 10 #include "ui/base/ui_base_export.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 enum Length { | 29 enum Length { |
| 30 LENGTH_SHORT, // Short format, e.g. in English: sec/min/hour/day. | 30 LENGTH_SHORT, // Short format, e.g. in English: sec/min/hour/day. |
| 31 LENGTH_LONG, // Long format, e.g. in English: second/minute/hour/day. | 31 LENGTH_LONG, // Long format, e.g. in English: second/minute/hour/day. |
| 32 LENGTH_COUNT // Enum size counter, not a length. Must be last. | 32 LENGTH_COUNT // Enum size counter, not a length. Must be last. |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 // Return a localized string of approximate time duration, formatted as a | 35 // Return a localized string of approximate time duration, formatted as a |
| 36 // single number, e.g. in English "2 hours ago". Currently, all combinations | 36 // single number, e.g. in English "2 hours ago". Currently, all combinations |
| 37 // of format and length except (FORMAT_ELAPSED, LENGTH_LONG) are implemented | 37 // of format and length are implemented. |
| 38 // but it's easy to add this, if required. | |
| 39 static base::string16 Simple(Format format, | 38 static base::string16 Simple(Format format, |
| 40 Length length, | 39 Length length, |
| 41 const base::TimeDelta& delta); | 40 const base::TimeDelta& delta); |
| 42 | 41 |
| 43 // Return a localized string of more precise time duration, either formatted | 42 // Return a localized string of more precise time duration, either formatted |
| 44 // as a single value or as two values: for a time delta of e.g. 2h19m either | 43 // as a single value or as two values: for a time delta of e.g. 2h19m either |
| 45 // "2 hours" or "2 hours and 19 minutes" could be returned in English. | 44 // "2 hours" or "2 hours and 19 minutes" could be returned in English. |
| 46 // Two-value output can be forced by setting |cutoff| to -1. Single-value | 45 // Two-value output can be forced by setting |cutoff| to -1. Single-value |
| 47 // output can be forced by using Simple() or setting |cutoff| to 0. | 46 // output can be forced by using Simple() or setting |cutoff| to 0. |
| 48 // Otherwise, choice of format happens automatically and the value of |cutoff| | 47 // Otherwise, choice of format happens automatically and the value of |cutoff| |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 static base::string16 RelativeDate(const base::Time& time, | 89 static base::string16 RelativeDate(const base::Time& time, |
| 91 const base::Time* optional_midnight_today); | 90 const base::Time* optional_midnight_today); |
| 92 | 91 |
| 93 private: | 92 private: |
| 94 DISALLOW_IMPLICIT_CONSTRUCTORS(TimeFormat); | 93 DISALLOW_IMPLICIT_CONSTRUCTORS(TimeFormat); |
| 95 }; | 94 }; |
| 96 | 95 |
| 97 } // namespace ui | 96 } // namespace ui |
| 98 | 97 |
| 99 #endif // UI_BASE_L10N_TIME_FORMAT_H_ | 98 #endif // UI_BASE_L10N_TIME_FORMAT_H_ |
| OLD | NEW |