Re: Filesystems patch for Daylight Savings Time

Mike Bremford (Mike.Bremford@mail.bl.uk)
Thu, 26 Sep 1996 15:31:16 +0100


Sorry to ruin your day...

I believe some Australian states have a DST of 1.5 hours or .5 hours -
can't remember which (or possibly both) apply.

Why not use the TZ things, or whatever it is that lives in
/usr/lib/zoneinfo?

Cheers... Mike

(PS. Why not send Linus gold bars instead of cash? Just a thought...)

______________________________ Reply Separator _________________________________
Subject: Filesystems patch for Daylight Savings Time
Author: Gordon Chaffee <chaffee@odie.cs.berkeley.edu> at Internet
Date: 25/09/96 11:09

Some time ago, there was a report of a bug when writing the times to
files on FAT filesystems when daylight savings time is in effect. The
problem is that conversions from local time to GMT time and vice versa
do not take into account daylight savings time. This problem seems to
affect the hpfs, vfat, msdos, smbfs, and ncpfs filesystems. I believe
it also affects affs, but I did not create a patch for it.

I looked into daylight savings time, and all daylight savings times that
I could find references to had offsets of one hour. If there are any
cases where daylight savings time has an offset different than an hour,
please let me know.

Here is a patch again linux-2.0.0 to fix this problem. It should apply to
just about any kernel since I don't believe the affected routines have been
changed it quite awhile.

Gordon Chaffee
chaffee@plateau.cs.berkeley.edu


--- linux/fs/hpfs/hpfs_fs.c.orig Tue Feb 20 00:28:13 1996
+++ linux/fs/hpfs/hpfs_fs.c Wed Sep 25 10:52:07 1996
@@ -321,7 +321,7 @@
static inline time_t local_to_gmt(time_t t)
{
extern struct timezone sys_tz;
- return t + sys_tz.tz_minuteswest * 60;
+ return t + sys_tz.tz_minuteswest * 60 - (sys_tz.tz_dsttime ? 3600 : 0);
}

/* super block ops */
--- linux/fs/smbfs/proc.c.orig Thu Jun 6 15:56:30 1996
+++ linux/fs/smbfs/proc.c Wed Sep 25 10:52:46 1996
@@ -169,13 +169,15 @@
static int
utc2local(int time)
{
- return time - sys_tz.tz_minuteswest*60;
+ return time - sys_tz.tz_minuteswest*60 +
+ (sys_tz.tz_dsttime ? 3600 : 0);
}

static int
local2utc(int time)
{
- return time + sys_tz.tz_minuteswest*60;
+ return time + sys_tz.tz_minuteswest*60 -
+ (sys_tz.tz_dsttime ? 3600 : 0);
}

/* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */
--- linux/fs/fat/misc.c.orig Fri May 17 11:44:39 1996
+++ linux/fs/fat/misc.c Wed Sep 25 10:53:27 1996
@@ -244,6 +244,9 @@
month < 2 ? 1 : 0)+3653);
/* days since 1.1.70 plus 80's leap day */
secs += sys_tz.tz_minuteswest*60;
+ if (sys_tz.tz_dsttime) {
+ secs -= 3600;
+ }
return secs;
}

--- linux/fs/ncpfs/dir.c.orig Tue Jun 4 16:12:18 1996
+++ linux/fs/ncpfs/dir.c Wed Sep 25 10:53:57 1996
@@ -1173,13 +1173,15 @@
static int
utc2local(int time)
{
- return time - sys_tz.tz_minuteswest*60;
+ return time - sys_tz.tz_minuteswest*60 +
+ (sys_tz.tz_dsttime ? 3600 : 0);
}

static int
local2utc(int time)
{
- return time + sys_tz.tz_minuteswest*60;
+ return time + sys_tz.tz_minuteswest*60 -
+ (sys_tz.tz_dsttime ? 3600 : 0);
}

/* Convert a MS-DOS time/date pair to a UNIX date (seconds since 1 1 70). */