Subject: Booter change request was Re: File system date wrong after install
To: Nico van Eikema Hommes <hommes@derioc1.organik.uni-erlangen.de>
From: Stephen C. Brown <sbrown@shellx.best.com>
List: port-mac68k
Date: 04/18/1997 18:20:35
Hi,

I think the "fug" here is in Think C, and/or the MacOS itself.  The
standard library "time()" function in Think C returns the time in
seconds since January 1904, apparently in the current time zone.  It
also appears that the MacOS is storing time in the current time zone
since "GetDateTime()"(a MacOS toolbox call) returns the exact same
number as the standard library "time()" function.  Adding to the
difficulty is the fact that the standard library "gmtime()" function
is busted in Think C and does exactly nothing.  The installer, of
course, uses the "time()" function to get the current time.  As I'll
have to reformat and reinstall one of my hard drives to do more
testing(currently using new style format), I'll confirm all of the
above tomorrow.

I am attaching code that will use the MacOS toolbox calls to get the
current Greenwich Mean Time delta, either in seconds or hours.  I'll
be including similar code in a patch release to the installer out
tomorrow(after a little testing).  The new installer will also
install 16 terminal device files, instead of 4.  It'll be
Installer 1.1e.  Yes, I know there have been an awful lot of
patch releases........;-)

I would like to request that whoever is currently maintaining the
booter use the attached code to make the booter automagically know
the correct GMT bias.  Mostly, this is so I don't have to keep
changing the booter settings when we go into and out of DST.

Thanks in advance,
Steve Brown,
sbrown@best.com

p.s.  The attached code is only for System 7 and up.  But, I think the
        Booter left System 6 out a long time ago.  If not, please include
        the appropriate checks for System 7 before doing the following.

--------------------------------------------------------------------------------
#include <Script.h>

struct MachineLocation  myLocation;
unsigned long           secondsDeltaGMT;
int                     hoursDeltaGMT;

        /* The MachineLocation record looks like the following:
                 struct MachineLocation {
                        Fract latitude;
                        Fract longitude;
                        union{
                                char dlsDelta;
                                long gmtDelta;
                        }gmtFlags;
                };
        */

        ReadLocation(&myLocation);

        if(myLocation.gmtFlags.dlsDelta)
          printf("In daylight savings time\n");

        /* GMT is stored in lower three bytes of gmtFlags */
        /* and DST flag is stored in upper byte.          */

        secondsDeltaGMT=myLocation.gmtFlags.gmtDelta;

        /* We now have to go through contortions to extend*/
        /* the sign into the upper byte.  Thanks, Apple.  */
        secondsDeltaGMT=secondsDeltaGMT & 0x00ffffff;
        if(secondsDeltaGMT & 0x00100000)
          secondsDeltaGMT|=0xff000000;

        printf("The GMT offset is %li seconds\n",secondsDeltaGMT);
        hoursDeltaGMT=(short) secondsDeltaGMT/(long) 3600;
        printf("The GMT offset is %+i hours\n",hoursDeltaGMT);


--------------------------------------------------------------------------------

>I think I have figured out what happens: it is a fug (that is a bug that
>would, in a Microsoft program, be called a "feature" :-> ) in the Installer.
>The timestamp is set to the local MacOS time (a cpin followed by ls shows
>this), but it should be set to GMT. When the filesystem is mounted during
>the boot process, the timestamp is interpreted as GMT, what it should be,
>and the offset, which for MET is positive, is added to it. That of course
>gives a later time than that of the battery clock.
>The irregularity of course came from the time elapsed between installing
>and booting. The negative offset for US-based systems probably caused this
>to remain unnoticed.
>
>Best wishes,
>
>           Nico
>
>--
>  Dr. N.J.R. van Eikema Hommes     Computer-Chemie-Centrum
>  hommes@ccc.uni-erlangen.de       Universitaet Erlangen-Nuernberg
>  Phone:    +49-(0)9131-856532     Naegelsbachstr. 25
>  FAX:      +49-(0)9131-856566     D-91052 Erlangen, Germany