v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
platform-posix-time.cc
Go to the documentation of this file.
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
#include <cmath>
6
7
#include "
src/base/platform/platform-posix-time.h
"
8
9
namespace
v8
{
10
namespace
base
{
11
12
const
char
*
PosixDefaultTimezoneCache::LocalTimezone
(
double
time) {
13
if
(std::isnan(time))
return
""
;
14
time_t tv =
static_cast<
time_t
>
(std::floor(time /
msPerSecond
));
15
struct
tm tm;
16
struct
tm* t = localtime_r(&tv, &tm);
17
if
(!t || !t->tm_zone)
return
""
;
18
return
t->tm_zone;
19
}
20
21
double
PosixDefaultTimezoneCache::LocalTimeOffset
(
double
time_ms,
bool
is_utc) {
22
// Preserve the old behavior for non-ICU implementation by ignoring both
23
// time_ms and is_utc.
24
time_t tv =
time
(
nullptr
);
25
struct
tm tm;
26
struct
tm* t = localtime_r(&tv, &tm);
27
DCHECK_NOT_NULL
(t);
28
// tm_gmtoff includes any daylight savings offset, so subtract it.
29
return
static_cast<
double
>
(t->tm_gmtoff *
msPerSecond
-
30
(t->tm_isdst > 0 ? 3600 *
msPerSecond
: 0));
31
}
32
33
}
// namespace base
34
}
// namespace v8
v8::base::PosixDefaultTimezoneCache::LocalTimezone
const char * LocalTimezone(double time_ms) override
Definition
platform-posix-time.cc:12
v8::base::PosixDefaultTimezoneCache::LocalTimeOffset
double LocalTimeOffset(double time_ms, bool is_utc) override
Definition
platform-posix-time.cc:21
v8::base::PosixTimezoneCache::msPerSecond
static const int msPerSecond
Definition
platform-posix.h:25
base
OpIndex base
Definition
instruction-selector-ia32.cc:65
time
TimeRecord time
Definition
js-temporal-objects.cc:79
v8
Definition
api-arguments-inl.h:19
platform-posix-time.h
DCHECK_NOT_NULL
#define DCHECK_NOT_NULL(val)
Definition
logging.h:492
src
base
platform
platform-posix-time.cc
Generated on Sun Apr 6 2025 21:08:50 for v8 by
1.12.0