On Mon, 29 Mar 1999, Robin Gilks wrote:

> The original question was not about NTP - I looked at that (now I recall)
> back in September and dismissed it as being totally over the top for the
> average ham running a 486dx66 & 8M as his interface to IP over radio .

I'm also not clear how NTP would cope in the situation where the MAC layer
could delay the packet's transmission by many seconds.

> Robin. G8ECJ - currently seeing the BST bit set in the MSF data stream
> and subtracting 3600 seconds from the decoded time to get back to
> GMT/UTC (yes I know the difference) because mktime() appears to be
> broken.

My mktime() seems badly broken too - i.e. not POSIX compliant.

A test script, using times around 1:00 a.m. GMT on 28 March 1999, when the EU
switched to Daylight Savings Time:


        #include <stdio.h>
        #include <time.h>
        
        char * stringtime(struct tm *);
        void print_zone_details(void);
        void do_it(int,int);
        
        int main(int argc, char **argv) {
                int hour,flag;
        
                for (hour = 0 ; 3 > hour ; hour ++) {
                        for (flag = -1 ; 2 > flag ; flag++) {
                                do_it(hour,flag);
                        }
                }
                print_zone_details();
                return 0;
        }
        
        void do_it(int hour, int flag)
        {
                time_t t;
                struct tm tm;
        
                tm.tm_year = 99;
                tm.tm_mon = 2;
                tm.tm_mday = 28;
                tm.tm_hour = hour;
                tm.tm_min = 30;
                tm.tm_sec = 0;
                tm.tm_isdst = flag; /* 0 = DST off, 1 = DST on, -1 = don't know */
        
                printf("For an input date of %02d-%02d-%04d %02d:%02d:%02d, with 
'isdst' set to %d:\n",
                  
tm.tm_mday,tm.tm_mon+1,tm.tm_year+1900,tm.tm_hour,tm.tm_min,tm.tm_sec,tm.tm_isdst);
        
                t=mktime(&tm);
                if (-1 == t) {
                        if (69 != tm.tm_year ) {
                                printf("Hmm, looks like mktime() blew up\n");
                        }
                }
                if (-1 == tm.tm_isdst ) {
                        printf("mktime() doesn't know whether DST is in effect or 
not\n");
                } else {
                        printf("mktime() says that DST is%s in effect\n",(1 == 
tm.tm_isdst) ? "" : "n't");
                }
        
                printf("%s\n",stringtime(gmtime(&t))),
                printf("%s\n",stringtime(localtime(&t)));
                printf("\n");
        
        }
        
        char * stringtime(struct tm *tb)
        {
                static char buffer[30];
        
                strftime(buffer,sizeof(buffer),"%a, %d %b %Y %H:%M:%S %Z\n",tb);
                return buffer;
        }
        
        void print_zone_details(void)
        {
                printf("Base Timezone offset is %ld seconds\n",timezone);
                printf("Daylight savings time is %s supported in the timezone\n",(1 == 
daylight) ? "" : "not");
                printf("Base Timezone name is %s\n",tzname[0]);
                if (1 == daylight) {
                        printf("DST Timezone name is %s\n",tzname[1]);
                }
        }


The output from my Linux glibc executable:

        For an input date of 28-03-1999 00:30:00, with 'isdst' set to -1:
        mktime() says that DST isn't in effect
        Sun, 28 Mar 1999 00:30:00 GMT
        Sun, 28 Mar 1999 00:30:00 GMT
        
        For an input date of 28-03-1999 00:30:00, with 'isdst' set to 0:
        mktime() says that DST isn't in effect
        Sun, 28 Mar 1999 00:30:00 GMT
        Sun, 28 Mar 1999 00:30:00 GMT
        
        For an input date of 28-03-1999 00:30:00, with 'isdst' set to 1:
        mktime() says that DST isn't in effect
        Sun, 28 Mar 1999 00:30:00 GMT
        Sun, 28 Mar 1999 00:30:00 GMT
        
        For an input date of 28-03-1999 01:30:00, with 'isdst' set to -1:
        Hmm, looks like mktime() blew up
        mktime() doesn't know whether DST is in effect or not
        Wed, 31 Dec 1969 23:59:59 GMT
        Thu, 01 Jan 1970 00:59:59 BST
        
        For an input date of 28-03-1999 01:30:00, with 'isdst' set to 0:
        Hmm, looks like mktime() blew up
        mktime() says that DST isn't in effect
        Wed, 31 Dec 1969 23:59:59 GMT
        Thu, 01 Jan 1970 00:59:59 BST
        
        For an input date of 28-03-1999 01:30:00, with 'isdst' set to 1:
        Hmm, looks like mktime() blew up
        mktime() says that DST is in effect
        Wed, 31 Dec 1969 23:59:59 GMT
        Thu, 01 Jan 1970 00:59:59 BST
        
        For an input date of 28-03-1999 02:30:00, with 'isdst' set to -1:
        mktime() says that DST is in effect
        Sun, 28 Mar 1999 01:30:00 GMT
        Sun, 28 Mar 1999 02:30:00 BST
        
        For an input date of 28-03-1999 02:30:00, with 'isdst' set to 0:
        mktime() says that DST is in effect
        Sun, 28 Mar 1999 01:30:00 GMT
        Sun, 28 Mar 1999 02:30:00 BST
        
        For an input date of 28-03-1999 02:30:00, with 'isdst' set to 1:
        mktime() says that DST is in effect
        Sun, 28 Mar 1999 01:30:00 GMT
        Sun, 28 Mar 1999 02:30:00 BST
        
        Base Timezone offset is -3600 seconds
        Daylight savings time is not supported in the timezone
        Base Timezone name is GMT


But from the same code running under HP-UX 10.20:

        For an input date of 28-03-1999 00:30:00, with 'isdst' set to -1:
        mktime() says that DST isn't in effect
        Sun, 28 Mar 1999 00:30:00 GMT
        Sun, 28 Mar 1999 00:30:00 GMT
        
        For an input date of 28-03-1999 00:30:00, with 'isdst' set to 0:
        mktime() says that DST isn't in effect
        Sun, 28 Mar 1999 00:30:00 GMT
        Sun, 28 Mar 1999 00:30:00 GMT
        
        For an input date of 28-03-1999 00:30:00, with 'isdst' set to 1:
        mktime() says that DST isn't in effect
        Sat, 27 Mar 1999 23:30:00 GMT
        Sat, 27 Mar 1999 23:30:00 GMT
        
        For an input date of 28-03-1999 01:30:00, with 'isdst' set to -1:
        mktime() says that DST isn't in effect
        Sun, 28 Mar 1999 00:30:00 GMT
        Sun, 28 Mar 1999 00:30:00 GMT
        
        For an input date of 28-03-1999 01:30:00, with 'isdst' set to 0:
        mktime() says that DST is in effect
        Sun, 28 Mar 1999 01:30:00 GMT
        Sun, 28 Mar 1999 02:30:00 BST
        
        For an input date of 28-03-1999 01:30:00, with 'isdst' set to 1:
        mktime() says that DST isn't in effect
        Sun, 28 Mar 1999 00:30:00 GMT
        Sun, 28 Mar 1999 00:30:00 GMT
        
        For an input date of 28-03-1999 02:30:00, with 'isdst' set to -1:
        mktime() says that DST is in effect
        Sun, 28 Mar 1999 01:30:00 GMT
        Sun, 28 Mar 1999 02:30:00 BST
        
        For an input date of 28-03-1999 02:30:00, with 'isdst' set to 0:
        mktime() says that DST is in effect
        Sun, 28 Mar 1999 02:30:00 GMT
        Sun, 28 Mar 1999 03:30:00 BST
        
        For an input date of 28-03-1999 02:30:00, with 'isdst' set to 1:
        mktime() says that DST is in effect
        Sun, 28 Mar 1999 01:30:00 GMT
        Sun, 28 Mar 1999 02:30:00 BST
        
        Base Timezone offset is 0 seconds
        Daylight savings time is  supported in the timezone
        Base Timezone name is GMT
        DST Timezone name is BST
                

Note that the Linux output doesn't always take note of isdst being set to 1,
that mktime() blows up at 1:30 (even though timezone = GMT is the only
correct answer at this time), and that the timezone variables are wrong.

Apart from that, it's OK :-)

73 Andrew G8FSL

--
Andrew Benham   [EMAIL PROTECTED]
Nortel Networks, London Road, Harlow, Essex CM17 9NA, United Kingdom
Tel: +44 1279 402372    Fax: +44 1279 405746

I speak for myself, my views are not necessarily the views
of Nortel Networks or any other corporation.

Reply via email to