Line data Source code
1 : // Copyright 2017 the V8 project 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 V8_BASE_TIMEZONE_CACHE_H_
6 : #define V8_BASE_TIMEZONE_CACHE_H_
7 :
8 : namespace v8 {
9 : namespace base {
10 :
11 62447 : class TimezoneCache {
12 : public:
13 : // Short name of the local timezone (e.g., EST)
14 : virtual const char* LocalTimezone(double time_ms) = 0;
15 :
16 : // ES #sec-daylight-saving-time-adjustment
17 : // Daylight Saving Time Adjustment
18 : virtual double DaylightSavingsOffset(double time_ms) = 0;
19 :
20 : // ES #sec-local-time-zone-adjustment
21 : // Local Time Zone Adjustment
22 : //
23 : // https://github.com/tc39/ecma262/pull/778
24 : virtual double LocalTimeOffset(double time_ms, bool is_utc) = 0;
25 :
26 : /**
27 : * Time zone redetection indicator for Clear function.
28 : *
29 : * kSkip indicates host time zone doesn't have to be redetected.
30 : * kRedetect indicates host time zone should be redetected, and used to set
31 : * the default time zone.
32 : *
33 : * The host time zone detection may require file system access or similar
34 : * operations unlikely to be available inside a sandbox. If v8 is run inside a
35 : * sandbox, the host time zone has to be detected outside the sandbox
36 : * separately.
37 : */
38 : enum class TimeZoneDetection { kSkip, kRedetect };
39 :
40 : // Called when the local timezone changes
41 : virtual void Clear(TimeZoneDetection time_zone_detection) = 0;
42 :
43 : // Called when tearing down the isolate
44 62432 : virtual ~TimezoneCache() = default;
45 : };
46 :
47 : } // namespace base
48 : } // namespace v8
49 :
50 : #endif // V8_BASE_TIMEZONE_CACHE_H_
|