Changeset 114085 in webkit
- Timestamp:
- Apr 12, 2012 11:07:40 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r114082 r114085 1 2012-04-12 Kent Tamura <tkent@chromium.org> 2 3 LocalizedDateICU should ignore timezones 4 https://bugs.webkit.org/show_bug.cgi?id=83859 5 6 Reviewed by Hajime Morita. 7 8 udat_parse() and udat_format() shift the input date by the offset of the 9 default timezone. We don't need this behavior for type=date. So we 10 specify "GMT" to udat_open(). 11 12 No new tests. This behavior depends on the timezone setting of the local machine. 13 14 * platform/text/LocalizedDateICU.cpp: 15 (WebCore::createShortDateFormatter): 16 Added. Common factory functio for UDateFormat. Use "GMT" instead of the 17 default timezone. 18 (WebCore::parseLocalizedDate): Use createShortDateFormatter(). 19 (WebCore::formatLocalizedDate): ditto. 20 1 21 2012-04-12 Adam Barth <abarth@webkit.org> 2 22 -
trunk/Source/WebCore/platform/text/LocalizedDateICU.cpp
r113422 r114085 44 44 namespace WebCore { 45 45 46 static inline UDateFormat* createShortDateFormatter() 47 { 48 const UChar gmtTimezone[3] = {'G', 'M', 'T'}; 49 UErrorCode status = U_ZERO_ERROR; 50 return udat_open(UDAT_NONE, UDAT_SHORT, defaultLanguage().utf8().data(), gmtTimezone, WTF_ARRAY_LENGTH(gmtTimezone), 0, -1, &status); 51 } 52 46 53 double parseLocalizedDate(const String& input, DateComponents::Type type) 47 54 { … … 51 58 break; 52 59 int32_t inputLength = static_cast<int32_t>(input.length()); 53 UErrorCode status = U_ZERO_ERROR; 54 UDateFormat* dateFormat = udat_open(UDAT_NONE, UDAT_SHORT, defaultLanguage().utf8().data(), 0, -1, 0, -1, &status); 60 UDateFormat* dateFormat = createShortDateFormatter(); 55 61 if (!dateFormat) 56 62 break; 57 status = U_ZERO_ERROR;63 UErrorCode status = U_ZERO_ERROR; 58 64 int32_t parsePosition = 0; 59 65 UDate date = udat_parse(dateFormat, input.characters(), inputLength, &parsePosition, &status); … … 79 85 switch (dateComponents.type()) { 80 86 case DateComponents::Date: { 81 UErrorCode status = U_ZERO_ERROR; 82 UDateFormat* dateFormat = udat_open(UDAT_NONE, UDAT_SHORT, defaultLanguage().utf8().data(), 0, -1, 0, -1, &status); 87 UDateFormat* dateFormat = createShortDateFormatter(); 83 88 if (!dateFormat) 84 89 break; 85 90 double input = dateComponents.millisecondsSinceEpoch(); 91 UErrorCode status = U_ZERO_ERROR; 86 92 int32_t length = udat_format(dateFormat, input, 0, 0, 0, &status); 87 93 if (status != U_BUFFER_OVERFLOW_ERROR) {
Note: See TracChangeset
for help on using the changeset viewer.