From 5f6725873d0f7f12b9e0bc4c7268018418928aec Mon Sep 17 00:00:00 2001 From: haotuo Date: Thu, 3 Nov 2022 17:02:07 +0800 Subject: [PATCH] read tzzone from system param if defined Signed-off-by: haotuo Change-Id: I06ca9d0ff471953fffc4bc5db0d00de366197ddb Signed-off-by: haotuo --- porting/linux/user/src/time/__tz.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/porting/linux/user/src/time/__tz.c b/porting/linux/user/src/time/__tz.c index 8951ef02..74f4dc4f 100755 --- a/porting/linux/user/src/time/__tz.c +++ b/porting/linux/user/src/time/__tz.c @@ -21,6 +21,10 @@ #include "libc.h" #include "lock.h" #include "time_impl.h" +#ifdef OHOS_ENABLE_PARAMETER +#include "sys_param.h" +#define SYSPARAM_LENGTH 40 +#endif #define __TZ_VERSION__ '2' @@ -152,7 +156,18 @@ static void do_tzset() s = getenv("TZ"); if (!s) { +#ifdef OHOS_ENABLE_PARAMETER + uint32_t tz_param_value_len = SYSPARAM_LENGTH; + char tz_param_value[SYSPARAM_LENGTH + 1] = {0}; + if (SystemReadParam("persist.time.timezone", tz_param_value, &tz_param_value_len) == 0) { + tz_param_value[tz_param_value_len] = 0; + s = tz_param_value; + } else { + s = "/etc/localtime"; + } +#else s = "/etc/localtime"; +#endif } if (!*s) { s = __utc; -- GitLab