summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2022-12-23 13:02:57 -0500
committerAndras Timar <andras.timar@collabora.com>2023-01-29 13:22:28 +0000
commite2d646665c4cb4c7eeb0a73cb5f460838589bef0 (patch)
tree42987bdec2a8e09af3b6cf70ad2b244c01d92136 /comphelper
parente3e259d551c0c8b7c106191f2c258e5929db1b29 (diff)
lok: support per-user timezone
This adds support for user-specific timezone. When none is provided during loading, the system default is used. Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk> Change-Id: Ie863450687eb82bc475268a09c9112e9fd50020f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144816 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit abaf8c0af1c6c7fe01276fdf2ae62419c7b0f654) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146211 Tested-by: Jenkins Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/lok.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index b11bf4e83582..1f07cd2614eb 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -8,6 +8,7 @@
*/
#include <comphelper/lok.hxx>
+#include <osl/process.h>
#include <i18nlangtag/languagetag.hxx>
#include <sal/log.hxx>
@@ -255,6 +256,24 @@ bool isAllowlistedLanguage(const OUString& lang)
#endif
}
+void setTimezone(bool isSet, const OUString& rTimezone)
+{
+ if (isSet)
+ {
+ // Set the given timezone, even if empty.
+ osl_setEnvironment(OUString("TZ").pData, rTimezone.pData);
+ }
+ else
+ {
+ // Unset and empty aren't the same.
+ // When unset, it means default to the system configured timezone.
+ osl_clearEnvironment(OUString("TZ").pData);
+ }
+
+ // Update the timezone data.
+ ::tzset();
+}
+
static void (*pStatusIndicatorCallback)(void *data, statusIndicatorCallbackType type, int percent, const char* pText)(nullptr);
static void *pStatusIndicatorCallbackData(nullptr);