OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ | |
6 #define CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ | |
7 | |
8 #include <map> | |
palmer
2013/02/05 19:57:51
You no longer need to include this.
Miguel Garcia
2013/02/06 11:39:44
Done.
| |
9 | |
10 #include "base/basictypes.h" | |
11 #include "third_party/icu/public/common/unicode/unistr.h" | |
12 #include "third_party/icu/public/i18n/unicode/gregocal.h" | |
13 #include "ui/base/ime/text_input_type.h" | |
14 | |
15 namespace WebKit { | |
16 struct WebDateTimeChooserParams; | |
17 } // namespace WebKit | |
18 | |
19 namespace content { | |
20 | |
21 // Converts between a text string representing a date/time and | |
22 // a set of year/month/day/hour/minute/second and viceversa. | |
palmer
2013/02/05 19:57:51
Nit: "vice versa" is two words. :)
Miguel Garcia
2013/02/06 11:39:44
Done.
| |
23 // It is timezone agnostic. | |
24 class DateTimeFormatter { | |
25 public: | |
26 explicit DateTimeFormatter(const WebKit::WebDateTimeChooserParams& source); | |
27 DateTimeFormatter( | |
28 ui::TextInputType type, | |
29 int year, int month, int day, int hour, int minute, int second); | |
30 ~DateTimeFormatter(); | |
31 | |
32 int GetYear() const; | |
33 int GetMonth() const; | |
34 int GetDay() const; | |
35 int GetHour() const; | |
36 int GetMinute() const; | |
37 int GetSecond() const; | |
38 ui::TextInputType GetType() const; | |
39 const std::string& GetFormattedValue() const; | |
40 | |
41 private: | |
42 void CreatePatternMap(); | |
43 bool ParseValues(); | |
44 const std::string FormatString() const; | |
45 int ExtractValue( | |
46 const icu::Calendar* calendar, UCalendarDateFields value) const; | |
47 void ExtractType(const WebKit::WebDateTimeChooserParams& source); | |
48 void ClearAll(); | |
49 | |
50 ui::TextInputType type_; | |
51 icu::UnicodeString patterns_[ui::TEXT_INPUT_TYPE_MAX + 1]; | |
52 int year_; | |
53 int month_; | |
54 int day_; | |
55 int hour_; | |
56 int minute_; | |
57 int second_; | |
58 const icu::UnicodeString* pattern_; | |
59 std::string formatted_string_; | |
60 | |
61 DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter); | |
62 }; | |
63 | |
64 } // namespace content | |
65 | |
66 #endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ | |
OLD | NEW |