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

Side by Side 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 unified diff | Download patch
OLDNEW
(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>
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.
23 // It is timezone agnostic.
24 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
25 public:
26 DateTimeFormatter(const WebKit::WebDateTimeChooserParams& source);
bulach 2013/02/05 11:54:56 nit: explicit
Miguel Garcia 2013/02/05 17:44:40 Done.
27 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.
28 int year, int month, int day, int hour, int minute, int second);
29 ~DateTimeFormatter();
30
31 int GetYear() const;
32 int GetMonth() const;
33 int GetDay() const;
34 int GetHour() const;
35 int GetMinute() const;
36 int GetSecond() const;
37 ui::TextInputType GetType();
38 std::string GetFormattedValue();
39
40 private:
41 void CreatePatternMap();
42 bool ParseValues();
43 const std::string FormatString() const;
44 int ExtractValue(
45 const icu::Calendar* calendar, UCalendarDateFields value) const;
46 void ExtractType(const WebKit::WebDateTimeChooserParams& source);
47 void ClearAll();
48
49 ui::TextInputType type_;
50 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
51 int year_;
52 int month_;
53 int day_;
54 int hour_;
55 int minute_;
56 int second_;
57 const icu::UnicodeString* pattern_;
58 std::string formatted_string_;
59
60 DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter);
61 };
62
63 } // namespace content
64
65 #endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698