Chromium Code Reviews| Index: content/renderer/date_time_formatter.h |
| diff --git a/content/renderer/date_time_formatter.h b/content/renderer/date_time_formatter.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b8f6b5146d8626e12fddfc69e955fe4880083a71 |
| --- /dev/null |
| +++ b/content/renderer/date_time_formatter.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ |
| +#define CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ |
| + |
| +#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.
|
| + |
| +#include "base/basictypes.h" |
| +#include "third_party/icu/public/common/unicode/unistr.h" |
| +#include "third_party/icu/public/i18n/unicode/gregocal.h" |
| +#include "ui/base/ime/text_input_type.h" |
| + |
| +namespace WebKit { |
| +struct WebDateTimeChooserParams; |
| +} // namespace WebKit |
| + |
| +namespace content { |
| + |
| +// Converts between a text string representing a date/time and |
| +// 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.
|
| +// It is timezone agnostic. |
| +class DateTimeFormatter { |
| + public: |
| + explicit DateTimeFormatter(const WebKit::WebDateTimeChooserParams& source); |
| + DateTimeFormatter( |
| + ui::TextInputType type, |
| + int year, int month, int day, int hour, int minute, int second); |
| + ~DateTimeFormatter(); |
| + |
| + int GetYear() const; |
| + int GetMonth() const; |
| + int GetDay() const; |
| + int GetHour() const; |
| + int GetMinute() const; |
| + int GetSecond() const; |
| + ui::TextInputType GetType() const; |
| + const std::string& GetFormattedValue() const; |
| + |
| + private: |
| + void CreatePatternMap(); |
| + bool ParseValues(); |
| + const std::string FormatString() const; |
| + int ExtractValue( |
| + const icu::Calendar* calendar, UCalendarDateFields value) const; |
| + void ExtractType(const WebKit::WebDateTimeChooserParams& source); |
| + void ClearAll(); |
| + |
| + ui::TextInputType type_; |
| + icu::UnicodeString patterns_[ui::TEXT_INPUT_TYPE_MAX + 1]; |
| + int year_; |
| + int month_; |
| + int day_; |
| + int hour_; |
| + int minute_; |
| + int second_; |
| + const icu::UnicodeString* pattern_; |
| + std::string formatted_string_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_ |