Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
scoped_set_tz.cpp
Go to the documentation of this file.
1
// Copyright 2021 The PDFium Authors
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
"testing/scoped_set_tz.h"
6
7
#
include
<
stdlib
.
h
>
8
#
include
<
time
.
h
>
9
10
#
include
"build/build_config.h"
11
#
include
"third_party/base/check_op.h"
12
13
namespace
{
14
15
constexpr
char
kTZ[] =
"TZ"
;
16
17
#
if
BUILDFLAG
(
IS_WIN
)
18
#
define
SETENV
(
name
,
value
)
_putenv_s
(
name
,
value
)
19
#
define
TZSET
_tzset
20
#
define
UNSETENV
(
name
)
_putenv_s
(
name
,
""
)
21
#
else
22
#
define
SETENV
(
name
,
value
)
setenv
(
name
,
value
,
1
)
23
#
define
TZSET
tzset
24
#
define
UNSETENV
(
name
)
unsetenv
(
name
)
25
#
endif
26
27
}
// namespace
28
29
ScopedSetTZ
::ScopedSetTZ(
const
std
::string& tz) {
30
const
char
* old_tz = getenv(kTZ);
31
if
(old_tz)
32
old_tz_ = old_tz;
33
34
CHECK_EQ(0,
SETENV
(kTZ, tz.c_str()));
35
TZSET
();
36
}
37
38
ScopedSetTZ
::~
ScopedSetTZ
() {
39
if
(old_tz_.has_value())
40
CHECK_EQ(0,
SETENV
(kTZ, old_tz_.value().c_str()));
41
else
42
CHECK_EQ(0,
UNSETENV
(kTZ));
43
TZSET
();
44
}
ScopedSetTZ
Definition
scoped_set_tz.h:13
ScopedSetTZ::~ScopedSetTZ
~ScopedSetTZ()
Definition
scoped_set_tz.cpp:38
std
Definition
qfloat16.h:493
TZSET
#define TZSET
Definition
scoped_set_tz.cpp:23
SETENV
#define SETENV(name, value)
Definition
scoped_set_tz.cpp:22
UNSETENV
#define UNSETENV(name)
Definition
scoped_set_tz.cpp:24
qtwebengine
src
3rdparty
chromium
third_party
pdfium
testing
scoped_set_tz.cpp
Generated on Mon Mar 10 2025 01:04:21 for Qt by
1.13.2