Commit 198f1940 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

Simplified CanonicalizeTimeZoneName

Support more 3 letters timezones and SystemV/XXX timezones

Bug: chromium:364374
Change-Id: I710eeee62ba65f7e30203a44a4bd2d95365cc6fc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2303896
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68925}
parent 04bc53b5
......@@ -371,35 +371,20 @@ class SpecialTimeZoneMap {
SpecialTimeZoneMap() {
Add("America/Argentina/ComodRivadavia");
Add("America/Knox_IN");
Add("Antarctica/DumontDUrville");
Add("Antarctica/McMurdo");
Add("Australia/ACT");
Add("Australia/LHI");
Add("Australia/NSW");
Add("Antarctica/DumontDUrville");
Add("Brazil/DeNoronha");
Add("CET");
Add("CST6CDT");
Add("Chile/EasterIsland");
Add("EET");
Add("EST");
Add("EST5EDT");
Add("GB");
Add("GB-Eire");
Add("HST");
Add("MET");
Add("MST");
Add("MST7MDT");
Add("Mexico/BajaNorte");
Add("Mexico/BajaSur");
Add("NZ");
Add("NZ-CHAT");
Add("PRC");
Add("PST8PDT");
Add("ROC");
Add("ROK");
Add("UCT");
Add("W-SU");
Add("WET");
}
std::string Find(const std::string& id) {
......@@ -426,7 +411,14 @@ std::string CanonicalizeTimeZoneID(const std::string& input) {
std::string upper = input;
transform(upper.begin(), upper.end(), upper.begin(),
LocaleIndependentAsciiToUpper);
if (upper.length() >= 3) {
if (upper.length() == 3) {
if (upper == "GMT") return "UTC";
// For id such as "CET", return upper case.
return upper;
} else if (upper.length() == 7 && '0' <= upper[3] && upper[3] <= '9') {
// For id such as "CST6CDT", return upper case.
return upper;
} else if (upper.length() > 3) {
if (memcmp(upper.c_str(), "ETC", 3) == 0) {
if (upper == "ETC/UTC" || upper == "ETC/GMT" || upper == "ETC/UCT") {
return "UTC";
......@@ -435,8 +427,7 @@ std::string CanonicalizeTimeZoneID(const std::string& input) {
return GetGMTTzID(input);
}
} else if (memcmp(upper.c_str(), "GMT", 3) == 0) {
if (upper == "GMT" || upper == "GMT0" || upper == "GMT+0" ||
upper == "GMT-0") {
if (upper == "GMT0" || upper == "GMT+0" || upper == "GMT-0") {
return "UTC";
}
} else if (memcmp(upper.c_str(), "US/", 3) == 0) {
......@@ -444,8 +435,9 @@ std::string CanonicalizeTimeZoneID(const std::string& input) {
// Change "Us/" to "US/"
title[1] = 'S';
return title;
} else if (upper == "UTC") {
return "UTC";
} else if (memcmp(upper.c_str(), "SYSTEMV/", 8) == 0) {
upper.replace(0, 8, "SystemV/");
return upper;
}
}
// We expect only _, '-' and / beside ASCII letters.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment