|
2 | 2 | #include "env-inl.h"
|
3 | 3 | #include "node_errors.h"
|
4 | 4 | #include "node_external_reference.h"
|
| 5 | +#include "node_i18n.h" |
5 | 6 | #include "node_process.h"
|
6 | 7 |
|
7 | 8 | #include <time.h> // tzset(), _tzset()
|
@@ -69,15 +70,32 @@ std::shared_ptr<KVStore> system_environment = std::make_shared<RealEnvStore>();
|
69 | 70 | } // namespace per_process
|
70 | 71 |
|
71 | 72 | template <typename T>
|
72 |
| -void DateTimeConfigurationChangeNotification(Isolate* isolate, const T& key) { |
| 73 | +void DateTimeConfigurationChangeNotification( |
| 74 | + Isolate* isolate, |
| 75 | + const T& key, |
| 76 | + const char* val = nullptr) { |
73 | 77 | if (key.length() == 2 && key[0] == 'T' && key[1] == 'Z') {
|
74 | 78 | #ifdef __POSIX__
|
75 | 79 | tzset();
|
| 80 | + isolate->DateTimeConfigurationChangeNotification( |
| 81 | + Isolate::TimeZoneDetection::kRedetect); |
76 | 82 | #else
|
77 | 83 | _tzset();
|
| 84 | + |
| 85 | +# if defined(NODE_HAVE_I18N_SUPPORT) |
| 86 | + isolate->DateTimeConfigurationChangeNotification( |
| 87 | + Isolate::TimeZoneDetection::kSkip); |
| 88 | + |
| 89 | + // On windows, the TZ environment is not supported out of the box. |
| 90 | + // By default, v8 will only be able to detect the system configured |
| 91 | + // timezone. This supports using the TZ environment variable to set |
| 92 | + // the default timezone instead. |
| 93 | + if (val != nullptr) i18n::SetDefaultTimeZone(val); |
| 94 | +# else |
| 95 | + isolate->DateTimeConfigurationChangeNotification( |
| 96 | + Isolate::TimeZoneDetection::kRedetect); |
| 97 | +# endif |
78 | 98 | #endif
|
79 |
| - auto constexpr time_zone_detection = Isolate::TimeZoneDetection::kRedetect; |
80 |
| - isolate->DateTimeConfigurationChangeNotification(time_zone_detection); |
81 | 99 | }
|
82 | 100 | }
|
83 | 101 |
|
@@ -128,7 +146,7 @@ void RealEnvStore::Set(Isolate* isolate,
|
128 | 146 | if (key.length() > 0 && key[0] == '=') return;
|
129 | 147 | #endif
|
130 | 148 | uv_os_setenv(*key, *val);
|
131 |
| - DateTimeConfigurationChangeNotification(isolate, key); |
| 149 | + DateTimeConfigurationChangeNotification(isolate, key, *val); |
132 | 150 | }
|
133 | 151 |
|
134 | 152 | int32_t RealEnvStore::Query(const char* key) const {
|
|
0 commit comments