[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Universal time makes me sad



Hello,

    I am still Lisping and life if pretty grand, however I have some very
strange behaviour in my program having to do with converting universal
time into seconds, minutes, hours etc.  I have written a program which
demonstrates this problem.  I hope someone can either point out the
error I am making or patch the interpreter.

	I am running System Software 7.0 on a Mac IIfx with 20 Meg of memory.
Virtual memory is off, 32 bit addressing is on.  I have MCL 2.0 from the
CD to which I have applied two patches bringing me to version 2.0p2.
Lisp is set to 6 Meg of memory.  Given the following program:

(defun test-time ()
  (do ((year 1993)
       time-in-seconds
       new-year
       month
       day
       hours
       minutes
       seconds)
      (nil)
    (setf month (1+ (random 11)))
    (setf day (1+ (random 27)))
    (setf hours (random 23))
    (setf minutes (random 59))
    (setf seconds (random 59))
    (setf time-in-seconds
          (encode-universal-time seconds minutes hours day month year 5))
    (multiple-value-bind (seconds minutes hours day month newyear)
                         (decode-universal-time time-in-seconds)
      (when (not (eq year newyear))
        (print-db year newyear)))))

The following output is produced:

? (test-time)

YEAR 1993
NEWYEAR -28007

YEAR 1993
NEWYEAR -28007

YEAR 1993
NEWYEAR -28007

YEAR 1993
NEWYEAR -28007

YEAR 1993
NEWYEAR -28007

YEAR 1993
NEWYEAR -28007
Aborted
? 

The error is sporadic i.e. decode-universal-time returns rational values
most of the time.

Does anyone have any comments on this?

Thanks,

Russell Owen
owen@dgp.utoronto.ca