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

Unified Diff: src/i18n.h

Issue 2724373002: [date] Add ICU backend for timezone info behind a flag (Closed)
Patch Set: ulan's formatting suggestion Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | src/i18n.cc » ('j') | src/i18n.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/i18n.h
diff --git a/src/i18n.h b/src/i18n.h
index f89d005b00c844309d925768f231c0bde94ca514..69a612120ce088f3ee60331b3b028e0f67bd2828 100644
--- a/src/i18n.h
+++ b/src/i18n.h
@@ -6,6 +6,7 @@
#ifndef V8_I18N_H_
#define V8_I18N_H_
+#include "src/base/timezone-cache.h"
#include "src/objects.h"
#include "unicode/uversion.h"
@@ -14,6 +15,7 @@ class BreakIterator;
class Collator;
class DecimalFormat;
class SimpleDateFormat;
+class TimeZone;
}
namespace v8 {
@@ -128,6 +130,54 @@ class V8BreakIterator {
V8BreakIterator();
};
+// ICUTimezoneCache calls out to ICU for TimezoneCache
+// functionality in a straightforward way.
+class ICUTimezoneCache : public base::TimezoneCache {
+ public:
+ ICUTimezoneCache();
+
+ ~ICUTimezoneCache() override;
+
+ const char* LocalTimezone(double time_ms) override;
+
+ double DaylightSavingsOffset(double time_ms) override;
+
+ double LocalTimeOffset() override;
+
+ void Clear() override;
+
+ private:
+ icu::TimeZone* GetTimeZone();
+
+ bool GetOffsets(double time_ms, int32_t* raw_offset, int32_t* dst_offset);
+
+ icu::TimeZone* timezone_;
+
+ static const int32_t kMaxTimezoneChars = 20;
+ char timezone_name_[kMaxTimezoneChars];
+ char dst_timezone_name_[kMaxTimezoneChars];
+};
+
+// ICUOSTimezoneCache defers to the OS TimezoneCache
+// for LocalTimezone if ICU provides a timezone name
+// which starts with GMT. Otherwise, it uses ICU for
+// all operaitons. The issue here is that CLDR declines
+// to specify short names for many time zones, when the
+// OS often does know an appropriate short name.
+class ICUOSTimezoneCache : public ICUTimezoneCache {
+ public:
+ ICUOSTimezoneCache();
+
+ ~ICUOSTimezoneCache() override;
+
+ const char* LocalTimezone(double time_ms) override;
+
+ void Clear() override;
+
+ private:
+ TimezoneCache* os_tz_cache_;
+};
+
} // namespace internal
} // namespace v8
« no previous file with comments | « src/flag-definitions.h ('k') | src/i18n.cc » ('j') | src/i18n.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698