Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1574)

Unified Diff: content/renderer/date_time_formatter.h

Issue 12191005: Move Android Date/Time parsing to the renderer (C++ and ICU) instead of the current parsing that ha… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..2bc1b6f351884093e2caf26434979cb99ddec5d2
--- /dev/null
+++ b/content/renderer/date_time_formatter.h
@@ -0,0 +1,65 @@
+// 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>
+
+#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.
+// It is timezone agnostic.
+class DateTimeFormatter {
bulach 2013/02/05 11:54:56 maybe TextInputDateTimeFormatter would be more app
Miguel Garcia 2013/02/05 17:44:40 I'll hold the renaming until the review is complet
Miguel Garcia 2013/02/07 10:55:32 Actually Date inputs are not text anymore. I can g
+ public:
+ DateTimeFormatter(const WebKit::WebDateTimeChooserParams& source);
bulach 2013/02/05 11:54:56 nit: explicit
Miguel Garcia 2013/02/05 17:44:40 Done.
+ DateTimeFormatter(ui::TextInputType type,
bulach 2013/02/05 11:54:56 nit: first param on the next line
Miguel Garcia 2013/02/05 17:44:40 Done.
+ 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();
+ std::string GetFormattedValue();
+
+ 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_;
+ std::map<ui::TextInputType, icu::UnicodeString> pattern_map_;
palmer 2013/02/04 22:14:08 Efficiency: This could be a static array instead o
Miguel Garcia 2013/02/05 17:44:40 This is a pretty good point. I changed it to an ar
+ 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_

Powered by Google App Engine
This is Rietveld 408576698