fix(os): Ubuntu 18.04 timezone error.
This commit is contained in:
parent
f21348a393
commit
a816e3034e
|
@ -172,6 +172,13 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
||||||
-timezone / 3600);
|
-timezone / 3600);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
char buf[4096] = {0};
|
||||||
|
char *tz = NULL;
|
||||||
|
{
|
||||||
|
int n = readlink("/etc/localtime", buf, sizeof(buf));
|
||||||
|
if (n < 0) {
|
||||||
|
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.
|
||||||
|
@ -228,12 +235,8 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
||||||
*/
|
*/
|
||||||
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
|
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz));
|
||||||
} else {
|
} else {
|
||||||
char buf[4096] = {0};
|
printf("There is not /etc/timezone.\n");
|
||||||
char *tz = NULL;
|
}
|
||||||
{
|
|
||||||
int n = readlink("/etc/localtime", buf, sizeof(buf));
|
|
||||||
if (n < 0) {
|
|
||||||
printf("read /etc/localtime error, reason:%s", strerror(errno));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf[n] = '\0';
|
buf[n] = '\0';
|
||||||
|
@ -272,6 +275,5 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) {
|
||||||
*/
|
*/
|
||||||
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %+03ld00)", tz, tm1.tm_isdst ? tzname[daylight] : tzname[0],
|
snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %+03ld00)", tz, tm1.tm_isdst ? tzname[daylight] : tzname[0],
|
||||||
-timezone / 3600);
|
-timezone / 3600);
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue