Skip to content
Tcl Source Code View Ticket
Login

View Ticket

clock-34.6 clock scan failure in NetBSD

Closed / Fixed1113146fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-01-31 13:02:33
With NetBSD 2.0 x86:

==== clock-34.6 clock scan tests FAILED
==== Contents of test case:

    set time [clock scan "Oct 23,1992 15:00"]
    clock format $time -format {%b %d,%Y %H:%M}

---- Test generated error; Return code was: 1
---- Return code should have been one of: 0 2
---- errorInfo: time value too large/small to represent
    while executing
"return -options $opts $result"
    (procedure "ConvertLocalToUTC" line 14)
    invoked from within
"ConvertLocalToUTC $date[set date {}]"
    (procedure "FreeScan" line 75)
    invoked from within
"FreeScan $string $base $timezone $locale"
    (procedure "::tcl::clock::scan" line 69)
    invoked from within
"clock scan "Oct 23,1992 15:00""
    invoked from within
"set time [clock scan "Oct 23,1992 15:00"]"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $script"
---- errorCode: NONE
==== clock-34.6 FAILED
georgeps Closed ticket [1113146fff]. [History diff]2005-02-01 07:04:45
georgepsplain2005-02-01 07:04:46
Logged In: YES 
user_id=585068

With the help of KBK we discovered that it's really the
problem that I don't have an /etc/localtime symlink on my
system.  The NetBSD installer creates this symlink, and the
manual page for afterboot mentions it at the top.  I removed
the symlink, because the clock is skewed in NetBSD (from the
BIOS and Windows).  The fix in my case is: 
# ln -s /usr/share/zoneinfo/US/Mountain /etc/localtime

There is an RTC_OFFSET kernel option for NetBSD that should
in theory fix this problem, and allow me to have the same
time for all operating systems, and the BIOS.

I wrote this test program to verify:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <time.h>

int main () { 
 struct tm t;

 t.tm_sec = 0;
 t.tm_min = 0;
 t.tm_hour = 14;
 t.tm_mday = 22;
 t.tm_mon = 9;
 t.tm_year = 2;
 t.tm_wday = 6;
 t.tm_yday = 297;

 if (-1 == mktime (&t)) {
  printf ("errno %d\n", errno);
  perror ("mktime");
  return EXIT_FAILURE;
 }

 return EXIT_SUCCESS;
}


Without /etc/localtime:
$ cc mktime_test.c  && ./a.out  
errno 2
mktime: No such file or directory
Log in (anonymous is fine) to add a comment.