lkml.org 
[lkml]   [1998]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectkernel knowledge of localtime (user-level implementation)

hi all,

this sort of died away awhile ago without resolution. as a number of
filesystems like to do things in local time, i would like to get it
resolved. in any case, here are my thoughts about giving the kernel
knowledge of local time:
1) it looks like we can just treat the timezone field of
settimeofday as implementation defined and use that.

2) if we set tz_dsttime = 0, and always make sure that
tz_minuteswest is correct, we don't have to worry about
dealing with daylight savings assumptions.

3) however, we do need to periodically inform the kernel of
changes to the timezone offset when they occur (e.g., you
just changed your timezone or daylight savings went into
effect).

i've tacked a snippet of code that does #1 and #2 on at the end. to
solve #3, though, we need someplace to stick it that gets called
periodically. i would like to stick it into the update daemon as it's
run periodically, has a snappy name, and is linux specific. comments?

-a

--------
#include <time.h>
#include <sys/time.h>

void set_timezone()
{
time_t t;
struct timezone tz;
static long old = 0;

t = time(NULL);
localtime(&t); /* set timezone */
if (old != timezone) {
old = timezone;
tz.tz_minuteswest = timezone / 60;
tz.tz_dsttime = 0;
settimeofday(NULL, &tz);
}
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:45    [W:0.027 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site