OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ | 5 #ifndef CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ |
6 #define CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ | 6 #define CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "third_party/icu/public/common/unicode/unistr.h" | 12 #include "third_party/icu/public/common/unicode/unistr.h" |
13 #include "third_party/icu/public/i18n/unicode/gregocal.h" | 13 #include "third_party/icu/public/i18n/unicode/gregocal.h" |
14 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
15 | 15 |
16 namespace WebKit { | 16 namespace WebKit { |
17 struct WebDateTimeChooserParams; | 17 struct WebDateTimeChooserParams; |
18 } // namespace WebKit | 18 } // namespace WebKit |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 // Converts between a text string representing a date/time and | 22 // Converts between a text string representing a date/time and |
23 // a set of year/month/day/hour/minute/second and vice versa. | 23 // a set of year/month/day/hour/minute/second and vice versa. |
24 // It is timezone agnostic. | 24 // It is timezone agnostic. |
25 class CONTENT_EXPORT DateTimeFormatter { | 25 class CONTENT_EXPORT DateTimeFormatter { |
26 public: | 26 public: |
27 explicit DateTimeFormatter(const WebKit::WebDateTimeChooserParams& source); | 27 explicit DateTimeFormatter(const WebKit::WebDateTimeChooserParams& source); |
28 DateTimeFormatter( | 28 DateTimeFormatter( |
29 ui::TextInputType type, | 29 ui::TextInputType type, |
30 int year, int month, int day, int hour, int minute, int second); | 30 int year, int month, int day, int hour, int minute, int second, |
| 31 int week_year, int week); |
31 ~DateTimeFormatter(); | 32 ~DateTimeFormatter(); |
32 | 33 |
33 int GetYear() const; | 34 int GetYear() const; |
34 int GetMonth() const; | 35 int GetMonth() const; |
35 int GetDay() const; | 36 int GetDay() const; |
36 int GetHour() const; | 37 int GetHour() const; |
37 int GetMinute() const; | 38 int GetMinute() const; |
38 int GetSecond() const; | 39 int GetSecond() const; |
| 40 int GetWeekYear() const; |
| 41 int GetWeek() const; |
39 ui::TextInputType GetType() const; | 42 ui::TextInputType GetType() const; |
40 const std::string& GetFormattedValue() const; | 43 const std::string& GetFormattedValue() const; |
41 | 44 |
42 private: | 45 private: |
43 void CreatePatternMap(); | 46 void CreatePatternMap(); |
44 bool ParseValues(); | 47 bool ParseValues(); |
45 const std::string FormatString() const; | 48 const std::string FormatString() const; |
46 int ExtractValue( | 49 int ExtractValue( |
47 const icu::Calendar* calendar, UCalendarDateFields value) const; | 50 const icu::Calendar* calendar, UCalendarDateFields value) const; |
48 void ExtractType(const WebKit::WebDateTimeChooserParams& source); | 51 void ExtractType(const WebKit::WebDateTimeChooserParams& source); |
49 void ClearAll(); | 52 void ClearAll(); |
50 | 53 |
51 ui::TextInputType type_; | 54 ui::TextInputType type_; |
52 icu::UnicodeString patterns_[ui::TEXT_INPUT_TYPE_MAX + 1]; | 55 icu::UnicodeString patterns_[ui::TEXT_INPUT_TYPE_MAX + 1]; |
53 int year_; | 56 int year_; |
54 int month_; | 57 int month_; |
55 int day_; | 58 int day_; |
56 int hour_; | 59 int hour_; |
57 int minute_; | 60 int minute_; |
58 int second_; | 61 int second_; |
| 62 int week_year_; |
| 63 int week_; |
59 const icu::UnicodeString* pattern_; | 64 const icu::UnicodeString* pattern_; |
60 std::string formatted_string_; | 65 std::string formatted_string_; |
61 | 66 |
62 DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter); | 67 DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter); |
63 }; | 68 }; |
64 | 69 |
65 } // namespace content | 70 } // namespace content |
66 | 71 |
67 #endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ | 72 #endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ |
OLD | NEW |