fix(query): fix timezone parsing for /usr/share/localtime
TD-16413 TD-16441
This commit is contained in:
parent
1359729848
commit
ee6343379c
|
@ -857,19 +857,27 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf[n] = '\0';
|
buf[n] = '\0';
|
||||||
for (int i = n - 1; i >= 0; --i) {
|
|
||||||
if (buf[i] == '/') {
|
char *zi = strstr(buf, "zoneinfo");
|
||||||
if (tz) {
|
if (!zi) {
|
||||||
tz = buf + i + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tz = buf + i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!tz || 0 == strchr(tz, '/')) {
|
|
||||||
printf("parsing /etc/localtime failed");
|
printf("parsing /etc/localtime failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tz = zi + strlen("zoneinfo") + 1;
|
||||||
|
|
||||||
|
//for (int i = n - 1; i >= 0; --i) {
|
||||||
|
// if (buf[i] == '/') {
|
||||||
|
// if (tz) {
|
||||||
|
// tz = buf + i + 1;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// tz = buf + i + 1;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//if (!tz || 0 == strchr(tz, '/')) {
|
||||||
|
// printf("parsing /etc/localtime failed");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
setenv("TZ", tz, 1);
|
setenv("TZ", tz, 1);
|
||||||
tzset();
|
tzset();
|
||||||
|
@ -900,7 +908,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
||||||
int n = readlink("/etc/localtime", buf, sizeof(buf));
|
int n = readlink("/etc/localtime", buf, sizeof(buf));
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
printf("read /etc/localtime error, reason:%s", strerror(errno));
|
printf("read /etc/localtime error, reason:%s", strerror(errno));
|
||||||
|
|
||||||
if (taosCheckExistFile("/etc/timezone")) {
|
if (taosCheckExistFile("/etc/timezone")) {
|
||||||
/*
|
/*
|
||||||
* NOTE: do not remove it.
|
* NOTE: do not remove it.
|
||||||
|
@ -962,19 +970,27 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf[n] = '\0';
|
buf[n] = '\0';
|
||||||
for (int i = n - 1; i >= 0; --i) {
|
|
||||||
if (buf[i] == '/') {
|
char *zi = strstr(buf, "zoneinfo");
|
||||||
if (tz) {
|
if (!zi) {
|
||||||
tz = buf + i + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tz = buf + i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!tz || 0 == strchr(tz, '/')) {
|
|
||||||
printf("parsing /etc/localtime failed");
|
printf("parsing /etc/localtime failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
tz = zi + strlen("zoneinfo") + 1;
|
||||||
|
|
||||||
|
//for (int i = n - 1; i >= 0; --i) {
|
||||||
|
// if (buf[i] == '/') {
|
||||||
|
// if (tz) {
|
||||||
|
// tz = buf + i + 1;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// tz = buf + i + 1;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//if (!tz || 0 == strchr(tz, '/')) {
|
||||||
|
// printf("parsing /etc/localtime failed");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
setenv("TZ", tz, 1);
|
setenv("TZ", tz, 1);
|
||||||
tzset();
|
tzset();
|
||||||
|
|
Loading…
Reference in New Issue