20 static const int kMsPerMin = 60 * 1000;
21 static const int kSecPerDay = 24 * 60 * 60;
22 static const int64_t kMsPerDay = kSecPerDay * 1000;
23 static const int64_t kMsPerMonth = kMsPerDay * 30;
26 static const int kMaxEpochTimeInSec =
kMaxInt;
27 static const int64_t kMaxEpochTimeInMs =
static_cast<int64_t
>(
kMaxInt) * 1000;
30 static const int64_t kMaxTimeInMs =
31 static_cast<int64_t
>(864000000) * 10000000;
35 static const int64_t kMaxTimeBeforeUTCInMs = kMaxTimeInMs + kMsPerMonth;
38 static const int kInvalidLocalOffsetInMs =
kMaxInt;
41 static const int kInvalidStamp = -1;
56 if (time_ms < 0) time_ms -= (kMsPerDay - 1);
57 return static_cast<int>(time_ms / kMsPerDay);
63 return static_cast<int>(time_ms -
days * kMsPerDay);
71 if (-kMaxTimeInMs <= *time && *time <= kMaxTimeInMs) {
74 *time = ((*time > 0) ? std::floor(*time) : std::ceil(*time)) + 0.0;
88 return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
92 int LocalOffsetInMs(int64_t time,
bool is_utc);
95 if (time_ms < 0 || time_ms > kMaxEpochTimeInMs) {
96 time_ms = EquivalentTime(time_ms);
98 bool is_dst = DaylightSavingsOffsetInMs(time_ms) != 0;
99 const char** name = is_dst ? &dst_tz_name_ : &tz_name_;
100 if (*name ==
nullptr) {
101 *name = tz_cache_->LocalTimezone(
static_cast<double>(time_ms));
108 int64_t local_ms =
ToLocal(time_ms);
109 return static_cast<int>((time_ms - local_ms) / kMsPerMin);
115 return time_ms + LocalOffsetInMs(time_ms,
true);
121 return time_ms - LocalOffsetInMs(time_ms,
false);
134 int days = DaysFromTime(time_ms);
135 int time_within_day_ms =
static_cast<int>(time_ms -
days * kMsPerDay);
136 int year, month, day;
137 YearMonthDayFromDays(
days, &year, &month, &day);
138 int new_days = DaysFromYearMonth(EquivalentYear(year), month) + day - 1;
139 return static_cast<int64_t
>(new_days) * kMsPerDay + time_within_day_ms;
147 int week_day = Weekday(DaysFromYearMonth(year, 0));
148 int recent_year = (IsLeap(year) ? 1956 : 1967) + (week_day * 12) % 28;
151 return 2008 + (recent_year + 3 * 28 - 2008) % 28;
156 void YearMonthDayFromDays(
int days,
int* year,
int* month,
int* day);
160 int DaysFromYearMonth(
int year,
int month);
163 void BreakDownTime(int64_t time_ms,
int* year,
int* month,
int* day,
164 int* weekday,
int*
hour,
int* min,
int* sec,
int* ms);
175 double time_ms =
static_cast<double>(time_sec * 1000);
176 return static_cast<int>(tz_cache_->DaylightSavingsOffset(time_ms));
179 virtual int GetLocalOffsetFromOS(int64_t time_ms,
bool is_utc);
186 static const int kDefaultTimeZoneOffsetDeltaInMs = 19 * kSecPerDay * 1000;
188 static const int kCacheSize = 32;
201 int time_sec = (time_ms >= 0 && time_ms <= kMaxEpochTimeInMs)
202 ?
static_cast<int>(time_ms / 1000)
203 :
static_cast<int>(EquivalentTime(time_ms) / 1000);
204 return GetDaylightSavingsOffsetFromOS(time_sec);
211 void ProbeCache(int64_t time_ms);
215 CacheItem* LeastRecentlyUsedCacheItem(CacheItem* skip);
219 inline void ExtendTheAfterSegment(int64_t time_sec,
int offset_ms);
222 inline void ClearSegment(CacheItem* segment);
255double MakeDate(
double day,
double time);
258double MakeDay(
double year,
double month,
double date);
261double MakeTime(
double hour,
double min,
double sec,
double ms);
virtual int GetDaylightSavingsOffsetFromOS(int64_t time_sec)
int EquivalentYear(int year)
static int TimeInDay(int64_t time_ms, int days)
bool InvalidSegment(CacheItem *segment)
int DaylightSavingsOffsetInMs(int64_t time_ms)
const char * LocalTimezone(int64_t time_ms)
base::TimezoneCache * tz_cache_
int64_t ToLocal(int64_t time_ms)
static bool TryTimeClip(double *time)
int64_t ToUTC(int64_t time_ms)
static int DaysFromTime(int64_t time_ms)
const char * dst_tz_name_
int TimezoneOffset(int64_t time_ms)
int64_t EquivalentTime(int64_t time_ms)
ZoneVector< RpoNumber > & result
double MakeDate(double day, double time)
DateBuffer ToDateString(double time_val, DateCache *date_cache, ToDateStringMode mode)
base::SmallVector< char, 128 > DateBuffer
double MakeDay(double year, double month, double date)
double MakeTime(double hour, double min, double sec, double ms)
double ParseDateTimeString(Isolate *isolate, DirectHandle< String > str)
bool ToLocal(v8::internal::MaybeDirectHandle< v8::internal::Object > maybe, Local< T > *local)
#define V8_EXPORT_PRIVATE