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/source/common/unicode/unistr.h" | 12 #include "third_party/icu/source/common/unicode/unistr.h" |
13 #include "third_party/icu/source/i18n/unicode/gregocal.h" | 13 #include "third_party/icu/source/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 blink { |
17 struct WebDateTimeChooserParams; | 17 struct WebDateTimeChooserParams; |
18 } // namespace WebKit | 18 } // namespace blink |
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/milli and vice versa. | 23 // a set of year/month/day/hour/minute/second/milli 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 blink::WebDateTimeChooserParams& source); |
28 DateTimeFormatter(ui::TextInputType type, | 28 DateTimeFormatter(ui::TextInputType type, |
29 int year, | 29 int year, |
30 int month, | 30 int month, |
31 int day, | 31 int day, |
32 int hour, | 32 int hour, |
33 int minute, | 33 int minute, |
34 int second, | 34 int second, |
35 int milli, | 35 int milli, |
36 int week_year, | 36 int week_year, |
37 int week); | 37 int week); |
(...skipping 10 matching lines...) Expand all Loading... |
48 int GetWeek() const; | 48 int GetWeek() const; |
49 ui::TextInputType GetType() const; | 49 ui::TextInputType GetType() const; |
50 const std::string& GetFormattedValue() const; | 50 const std::string& GetFormattedValue() const; |
51 | 51 |
52 private: | 52 private: |
53 void CreatePatternMap(); | 53 void CreatePatternMap(); |
54 bool ParseValues(); | 54 bool ParseValues(); |
55 const std::string FormatString() const; | 55 const std::string FormatString() const; |
56 int ExtractValue( | 56 int ExtractValue( |
57 const icu::Calendar* calendar, UCalendarDateFields value) const; | 57 const icu::Calendar* calendar, UCalendarDateFields value) const; |
58 void ExtractType(const WebKit::WebDateTimeChooserParams& source); | 58 void ExtractType(const blink::WebDateTimeChooserParams& source); |
59 void ClearAll(); | 59 void ClearAll(); |
60 | 60 |
61 ui::TextInputType type_; | 61 ui::TextInputType type_; |
62 icu::UnicodeString patterns_[ui::TEXT_INPUT_TYPE_MAX + 1]; | 62 icu::UnicodeString patterns_[ui::TEXT_INPUT_TYPE_MAX + 1]; |
63 icu::UnicodeString time_pattern_; | 63 icu::UnicodeString time_pattern_; |
64 int year_; | 64 int year_; |
65 int month_; | 65 int month_; |
66 int day_; | 66 int day_; |
67 int hour_; | 67 int hour_; |
68 int minute_; | 68 int minute_; |
69 int second_; | 69 int second_; |
70 int milli_; | 70 int milli_; |
71 int week_year_; | 71 int week_year_; |
72 int week_; | 72 int week_; |
73 const icu::UnicodeString* pattern_; | 73 const icu::UnicodeString* pattern_; |
74 std::string formatted_string_; | 74 std::string formatted_string_; |
75 | 75 |
76 DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter); | 76 DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter); |
77 }; | 77 }; |
78 | 78 |
79 } // namespace content | 79 } // namespace content |
80 | 80 |
81 #endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ | 81 #endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ |
OLD | NEW |