From ad34885a2b97ea4e21f9ac34c3109d02f5cb0f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 13 May 2006 15:52:32 +0000 Subject: [PATCH] actually set timezone in the kernel, and in the settings should help on bug #583, and even fix it minor change in localtime git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17441 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/os/time.c | 27 ++++++++++++++++++++++- src/system/libroot/posix/time/localtime.c | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/system/libroot/os/time.c b/src/system/libroot/os/time.c index 46da5e97a7..0556e920e7 100644 --- a/src/system/libroot/os/time.c +++ b/src/system/libroot/os/time.c @@ -4,8 +4,10 @@ */ +#include #include +#include #include #include @@ -62,10 +64,33 @@ set_real_time_clock(uint32 secs) status_t set_timezone(char *timezone) { - // ToDo: set_timezone() + char path[B_PATH_NAME_LENGTH]; + char tzfilename[B_PATH_NAME_LENGTH]; + bool isGMT; + status_t err; struct tm *tm; time_t t; + + if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path, B_PATH_NAME_LENGTH)) != B_OK) { + fprintf(stderr, "can't find settings directory: %s\n", strerror(err)); + return err; + } + strcat(path, "/timezone"); + + err = unlink(path); + if (err != B_OK) { + fprintf(stderr, "can't unlink: %s\n", strerror(err)); + return err; + } + err = symlink(timezone, path); + if (err != B_OK) { + fprintf(stderr, "can't symlink: %s\n", strerror(err)); + return err; + } + _kern_get_tzfilename(tzfilename, sizeof(tzfilename), &isGMT); + _kern_set_tzfilename(timezone, strlen(timezone), isGMT); + tzset(); time(&t); tm = localtime(&t); diff --git a/src/system/libroot/posix/time/localtime.c b/src/system/libroot/posix/time/localtime.c index a170741569..b910f07e7c 100644 --- a/src/system/libroot/posix/time/localtime.c +++ b/src/system/libroot/posix/time/localtime.c @@ -1057,7 +1057,7 @@ tzset P((void)) name = getenv("TZ"); if (name == NULL) { - _kern_get_tzfilename(tzfilename, B_PATH_NAME_LENGTH, &is_gmt); + _kern_get_tzfilename(tzfilename, sizeof(tzfilename), &is_gmt); if (tzfilename[0] == '\0') { tzsetwall(); return;