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

What is the time anyways?

    This may be a novice question but I am really stumped.  I am trying to
write a function that returns the current time read from the mac's
real-time clock.  It would seem to be a simple task.

The function:

(load "ccl:library;interfaces;OSUTILS.lisp")

(defun get-current-hms ()
  (rlet ((ctime DateTimeRec)
         (stime signed-long))
    (#_getdatetime stime)
    (setq tTime (%get-unsigned-long stime))
    (#_secs2date tTime ctime)
    (format nil "~2,'0D:~2,'0D:~2,'0D"
            (rref ctime DateTimeRec.hour)
            (rref ctime DateTimeRec.minute)
            (rref ctime DateTimeRec.second))))

should work.  Instead it prints a value that is rapidly decreasing and
which rolls around to 24:00:00 every few seconds.  The mysterious part is
that the value of tTime is correct.  If I print out tTime and then
copy the numeric constant into the function so the call to secs2date() is
    (#_secs2date 2806051999 ctime)
then the fields of ctime are set correctly.  Making the call to secs2date()
look like this:
    (#_secs2date (%get-unsigned-long stime) ctime)
exhibits the same strange decrementing behaviour.  Calling gettime()
directly also gives the rapidly decrementing time.

I am programming on a mac IIfx running system 7.0
The Lisp I am using is version 2.0 from the CD Rom without any patches.
If anyone has any idea I would appreciate the help since I am getting
a great deal of work done very quickly with MCL and it seems a shame to
be hung up on such a small problem.


Russell Owen