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

Side by Side Diff: Source/core/platform/DateComponents.h

Issue 18318002: DateComponents shouldn't use bloatedCharacters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix build Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/html/WeekInputType.cpp ('k') | Source/core/platform/DateComponents.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // The following six functions parse the input 'src' whose length is 95 // The following six functions parse the input 'src' whose length is
96 // 'length', and updates some fields of this instance. The parsing starts at 96 // 'length', and updates some fields of this instance. The parsing starts at
97 // src[start] and examines characters before src[length]. 97 // src[start] and examines characters before src[length].
98 // 'src' must be non-null. The 'src' string doesn't need to be 98 // 'src' must be non-null. The 'src' string doesn't need to be
99 // null-terminated. 99 // null-terminated.
100 // The functions return true if the parsing succeeds, and set 'end' to the 100 // The functions return true if the parsing succeeds, and set 'end' to the
101 // next index after the last consumed. Extra leading characters cause parse 101 // next index after the last consumed. Extra leading characters cause parse
102 // failures, and the trailing extra characters don't cause parse failures. 102 // failures, and the trailing extra characters don't cause parse failures.
103 103
104 // Sets year and month. 104 // Sets year and month.
105 bool parseMonth(const UChar* src, unsigned length, unsigned start, unsigned& end); 105 bool parseMonth(const String&, unsigned start, unsigned& end);
106 // Sets year, month and monthDay. 106 // Sets year, month and monthDay.
107 bool parseDate(const UChar* src, unsigned length, unsigned start, unsigned& end); 107 bool parseDate(const String&, unsigned start, unsigned& end);
108 // Sets year and week. 108 // Sets year and week.
109 bool parseWeek(const UChar* src, unsigned length, unsigned start, unsigned& end); 109 bool parseWeek(const String&, unsigned start, unsigned& end);
110 // Sets hour, minute, second and millisecond. 110 // Sets hour, minute, second and millisecond.
111 bool parseTime(const UChar* src, unsigned length, unsigned start, unsigned& end); 111 bool parseTime(const String&, unsigned start, unsigned& end);
112 // Sets year, month, monthDay, hour, minute, second and millisecond. 112 // Sets year, month, monthDay, hour, minute, second and millisecond.
113 bool parseDateTimeLocal(const UChar* src, unsigned length, unsigned start, u nsigned& end); 113 bool parseDateTimeLocal(const String&, unsigned start, unsigned& end);
114 // Sets year, month, monthDay, hour, minute, second and millisecond, and adj usts timezone. 114 // Sets year, month, monthDay, hour, minute, second and millisecond, and adj usts timezone.
115 bool parseDateTime(const UChar* src, unsigned length, unsigned start, unsign ed& end); 115 bool parseDateTime(const String&, unsigned start, unsigned& end);
116 116
117 // The following setMillisecondsSinceEpochFor*() functions take 117 // The following setMillisecondsSinceEpochFor*() functions take
118 // the number of milliseconds since 1970-01-01 00:00:00.000 UTC as 118 // the number of milliseconds since 1970-01-01 00:00:00.000 UTC as
119 // the argument, and update all fields for the corresponding 119 // the argument, and update all fields for the corresponding
120 // DateComponents type. The functions return true if it succeeds, and 120 // DateComponents type. The functions return true if it succeeds, and
121 // false if they fail. 121 // false if they fail.
122 122
123 // For Date type. Updates m_year, m_month and m_monthDay. 123 // For Date type. Updates m_year, m_month and m_monthDay.
124 bool setMillisecondsSinceEpochForDate(double ms); 124 bool setMillisecondsSinceEpochForDate(double ms);
125 // For DateTime type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond. 125 // For DateTime type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Date in ECMAScript can't represent dates later than 275760-09-13T00:00Z. 165 // Date in ECMAScript can't represent dates later than 275760-09-13T00:00Z.
166 // So, we have the same upper limit in HTML5 date/time types. 166 // So, we have the same upper limit in HTML5 date/time types.
167 static inline int maximumYear() { return 275760; } 167 static inline int maximumYear() { return 275760; }
168 static const int minimumWeekNumber; 168 static const int minimumWeekNumber;
169 static const int maximumWeekNumber; 169 static const int maximumWeekNumber;
170 170
171 private: 171 private:
172 // Returns the maximum week number in this DateComponents's year. 172 // Returns the maximum week number in this DateComponents's year.
173 // The result is either of 52 and 53. 173 // The result is either of 52 and 53.
174 int maxWeekNumberInYear() const; 174 int maxWeekNumberInYear() const;
175 bool parseYear(const UChar* src, unsigned length, unsigned start, unsigned& end); 175 bool parseYear(const String&, unsigned start, unsigned& end);
176 bool addDay(int); 176 bool addDay(int);
177 bool addMinute(int); 177 bool addMinute(int);
178 bool parseTimeZone(const UChar* src, unsigned length, unsigned start, unsign ed& end); 178 bool parseTimeZone(const String&, unsigned start, unsigned& end);
179 // Helper for millisecondsSinceEpoch(). 179 // Helper for millisecondsSinceEpoch().
180 double millisecondsSinceEpochForTime() const; 180 double millisecondsSinceEpochForTime() const;
181 // Helpers for setMillisecondsSinceEpochFor*(). 181 // Helpers for setMillisecondsSinceEpochFor*().
182 bool setMillisecondsSinceEpochForDateInternal(double ms); 182 bool setMillisecondsSinceEpochForDateInternal(double ms);
183 void setMillisecondsSinceMidnightInternal(double ms); 183 void setMillisecondsSinceMidnightInternal(double ms);
184 // Helper for toString(). 184 // Helper for toString().
185 String toStringForTime(SecondFormat) const; 185 String toStringForTime(SecondFormat) const;
186 186
187 // m_weekDay values 187 // m_weekDay values
188 enum { 188 enum {
(...skipping 15 matching lines...) Expand all
204 int m_year; // 1582 - 204 int m_year; // 1582 -
205 int m_week; // 1 - 53 205 int m_week; // 1 - 53
206 206
207 Type m_type; 207 Type m_type;
208 }; 208 };
209 209
210 210
211 } // namespace WebCore 211 } // namespace WebCore
212 212
213 #endif // DateComponents_h 213 #endif // DateComponents_h
OLDNEW
« no previous file with comments | « Source/core/html/WeekInputType.cpp ('k') | Source/core/platform/DateComponents.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698