RE: i386/RTC: old problem, new solution?

Riley Williams (rhw@MemAlpha.CX)
Fri, 21 May 1999 00:02:46 +0100 (GMT)


Hi Nick.

> The code to handle all the combinations of time zone and
> daylight savings rules correctly, would probably be of
> non-trivial size, and also require users to patch / upgrade
> their kernel when the legislation changed in various countries.
> France came close to unilatrally abolishing DST a year or two
> back, and the whole EU may well abandon it in 2001.

As far as I can see, it can be done quite simply using just two kernel
parameters, pseudocoded as follows:

Q> kernel_var __s16 rtctz = (default) +0 /* minutes */
Q> kernel_var __s8 rtcdst = (default) +60 /* minutes */

These are defined as follows:

Q> rtctz = (localtime - UTC) expressed in minutes. The default
Q> needs to be specified by a compile-time BOOLEAN, the
Q> two valid defaults being +0 for systems where the
Q> RTC reports UTC, and the timezone difference of the
Q> compiling system where it doesn't.

Q> rtcdst = (DST - nonDST) expressed in minutes. The default in
Q> this case should always be +60.

Given those two variables, the relevant pseudocode reduces to the
following function:

Q> time_t gettime(void) {
Q> time_t sysclock
Q>
Q> set sysclock to value in RTC treated as UTC
Q> sysclock -= 60 * rtctz
Q> if (RTC reports DST in use) {
Q> sysclock += 60 * rtcdst
Q> }
Q> return sysclock
Q> }

I think you were assuming that the routines to determine the DST dates
would need to be in the kernel as well, and I'd agree that suchlike
routines would be far too much kernel bloat, but they're not needed
for the purposes stated, as the above will achieve the same purpose.

Best wishes from Riley.

+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* ftp://ftp.MemAlpha.cx/pub/rhw/Linux
* http://www.MemAlpha.cx/kernel.versions.html

-
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/