| // Copyright 2021 The PDFium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| #include "testing/scoped_set_tz.h" |
| #include "build/build_config.h" |
| #include "core/fxcrt/check_op.h" |
| constexpr char kTZ[] = "TZ"; |
| #define SETENV(name, value) _putenv_s(name, value) |
| #define UNSETENV(name) _putenv_s(name, "") |
| #define SETENV(name, value) setenv(name, value, 1) |
| #define UNSETENV(name) unsetenv(name) |
| ScopedSetTZ::ScopedSetTZ(const std::string& tz) { |
| const char* old_tz = getenv(kTZ); |
| CHECK_EQ(0, SETENV(kTZ, tz.c_str())); |
| ScopedSetTZ::~ScopedSetTZ() { |
| CHECK_EQ(0, SETENV(kTZ, old_tz_.value().c_str())); |
| CHECK_EQ(0, UNSETENV(kTZ)); |