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
This commit is contained in:
@@ -4,8 +4,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <FindDirectory.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
@@ -62,11 +64,34 @@ set_real_time_clock(uint32 secs)
|
|||||||
status_t
|
status_t
|
||||||
set_timezone(char *timezone)
|
set_timezone(char *timezone)
|
||||||
{
|
{
|
||||||
// ToDo: set_timezone()
|
char path[B_PATH_NAME_LENGTH];
|
||||||
|
char tzfilename[B_PATH_NAME_LENGTH];
|
||||||
|
bool isGMT;
|
||||||
|
|
||||||
status_t err;
|
status_t err;
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
time_t t;
|
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);
|
time(&t);
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
|
|
||||||
|
|||||||
@@ -1057,7 +1057,7 @@ tzset P((void))
|
|||||||
|
|
||||||
name = getenv("TZ");
|
name = getenv("TZ");
|
||||||
if (name == NULL) {
|
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') {
|
if (tzfilename[0] == '\0') {
|
||||||
tzsetwall();
|
tzsetwall();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user