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_
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"
17 struct WebDateTimeChooserParams
;
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
{
27 explicit DateTimeFormatter(const WebKit::WebDateTimeChooserParams
& source
);
28 DateTimeFormatter(ui::TextInputType type
,
44 int GetMinute() const;
45 int GetSecond() const;
47 int GetWeekYear() const;
49 ui::TextInputType
GetType() const;
50 const std::string
& GetFormattedValue() const;
53 void CreatePatternMap();
55 const std::string
FormatString() const;
57 const icu::Calendar
* calendar
, UCalendarDateFields value
) const;
58 void ExtractType(const WebKit::WebDateTimeChooserParams
& source
);
61 ui::TextInputType type_
;
62 icu::UnicodeString patterns_
[ui::TEXT_INPUT_TYPE_MAX
+ 1];
63 icu::UnicodeString time_pattern_
;
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_