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

Side by Side Diff: content/renderer/date_time_formatter.h

Issue 85643002: Transfer date/time value to chooser as double (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@doubledate2
Patch Set: Created 7 years 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 <string>
9
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"
15
16 namespace blink {
17 struct WebDateTimeChooserParams;
18 } // namespace blink
19
20 namespace content {
21
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 blink::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();
39
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;
51
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 blink::WebDateTimeChooserParams& source);
59 void ClearAll();
60
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_;
75
76 DISALLOW_COPY_AND_ASSIGN(DateTimeFormatter);
77 };
78
79 } // namespace content
80
81 #endif // CONTENT_RENDERER_DATE_TIME_FORMATTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698