未验证 提交 f7b218d2 编写于 作者: O openharmony_ci 提交者: Gitee

!646 read tzzone from system param

Merge pull request !646 from haotuo/add_get_param_for_tzzone
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#include "libc.h" #include "libc.h"
#include "lock.h" #include "lock.h"
#include "time_impl.h" #include "time_impl.h"
#ifdef OHOS_ENABLE_PARAMETER
#include "sys_param.h"
#define SYSPARAM_LENGTH 40
#endif
#define __TZ_VERSION__ '2' #define __TZ_VERSION__ '2'
...@@ -152,7 +156,18 @@ static void do_tzset() ...@@ -152,7 +156,18 @@ static void do_tzset()
s = getenv("TZ"); s = getenv("TZ");
if (!s) { 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"; s = "/etc/localtime";
#endif
} }
if (!*s) { if (!*s) {
s = __utc; s = __utc;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册