kernel knowledge of localtime (user-level implementation)

a sun (asun@saul10.u.washington.edu)
Mon, 23 Nov 1998 11:26:01 -0800 (PST)


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/