diff options
author | James M Snell <jasnell@gmail.com> | 2021-05-11 19:10:46 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2021-05-17 22:02:49 +0300 |
commit | 16cb4f720b43345c9ed34f4a67165e86fbba5b90 (patch) | |
tree | 04fdde70aa88178e21ecc71b4d60b0ed932c0255 /src/node_i18n.cc | |
parent | 75340f3c524cbe8602ba8f5a48b8bf8572bad8f1 (diff) |
lib: support setting process.env.TZ on windows
Fixes: https://github.com/nodejs/node/issues/4230
Signed-off-by: James M Snell <jasnell@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/38642
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'src/node_i18n.cc')
-rw-r--r-- | src/node_i18n.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/node_i18n.cc b/src/node_i18n.cc index 42e618ac301..1b105cc9e56 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -542,6 +542,16 @@ bool InitializeICUDirectory(const std::string& path) { return status == U_ZERO_ERROR; } +void SetDefaultTimeZone(const char* tzid) { + size_t tzidlen = strlen(tzid) + 1; + UErrorCode status = U_ZERO_ERROR; + MaybeStackBuffer<UChar, 256> id(tzidlen); + u_charsToUChars(tzid, id.out(), tzidlen); + // This is threadsafe: + ucal_setDefaultTimeZone(id.out(), &status); + CHECK(U_SUCCESS(status)); +} + int32_t ToUnicode(MaybeStackBuffer<char>* buf, const char* input, size_t length) { |