Remove unused Device Motion IPC messages.
[chromium-blink-merge.git] / content / renderer / date_time_formatter.h
blobb2b73410216be8e0ecc00e53cb04d7274ca46ada
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.
5 #ifndef CONTENT_RENDERER_DATE_TIME_FORMATTER_H_
6 #define CONTENT_RENDERER_DATE_TIME_FORMATTER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "content/common/content_export.h"
12 #include "third_party/icu/source/common/unicode/unistr.h"
13 #include "third_party/icu/source/i18n/unicode/gregocal.h"
14 #include "ui/base/ime/text_input_type.h"
16 namespace WebKit {
17 struct WebDateTimeChooserParams;
18 } // namespace WebKit
20 namespace content {
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.
24 // It is timezone agnostic.
25 class CONTENT_EXPORT DateTimeFormatter {
26 public:
27 explicit DateTimeFormatter(const WebKit::WebDateTimeChooserParams& source);
28 DateTimeFormatter(ui::TextInputType type,
29 int year,
30 int month,
31 int day,
32 int hour,
33 int minute,
34 int second,
35 int milli,
36 int week_year,
37 int week);
38 ~DateTimeFormatter();
40 int GetYear() const;
41 int GetMonth() const;
42 int GetDay() const;
43 int GetHour() const;
44 int GetMinute() const;
45 int GetSecond() const;
46 int GetMilli() const;
47 int GetWeekYear() const;
48 int GetWeek() const;
49 ui::TextInputType GetType() const;
50 const std::string& GetFormattedValue() const;
52 private:
53 void CreatePatternMap();
54 bool ParseValues();
55 const std::string FormatString() const;
56 int ExtractValue(
57 const icu::Calendar* calendar, UCalendarDateFields value) const;
58 void ExtractType(const WebKit::WebDateTimeChooserParams& source);
59 void ClearAll();
61 ui::TextInputType type_;
62 icu::UnicodeString patterns_[ui::TEXT_INPUT_TYPE_MAX + 1];
63 icu::UnicodeString time_pattern_;
64 int year_;
65 int month_;
66 int day_;
67 int hour_;
68 int minute_;
69 int second_;
70 int milli_;
71 int week_year_;
72 int week_;
73 const icu::UnicodeString* pattern_;
74 std::string formatted_string_;
76 DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter);
79 } // namespace content
81 #endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_