[Openmcl-devel] encode-universal-time bug?

Gary Byers gb at clozure.com
Thu Sep 19 19:59:48 UTC 2002



On Thu, 19 Sep 2002, Gary Byers wrote:

>
>
> On Thu, 19 Sep 2002, John DeSoi wrote:
>
> > ? (encode-universal-time 0 0 0 1 1 1900)
> > >  Error: value -2208988800 is not of the expected type INTEGER.
>
> Not exactly a sensible error message, either.

I still haven't fixed that.

>
> > >  While executing: CCL::GET-TIMEZONE
> > >  Type :POP to abort.
> >
> >
> > On MCL this returns 18000
> >

Clearly, one of us is in the wrong time zone:
? (encode-universal-time 0 0 0 1 1 1900)
25200

> > Best,
>
> Thanks.
>
> Inspecting/describing a small integer fails, quite possibly becuase of
> the same bug.
>
> >
> > John DeSoi, Ph.D.
> >
> > _______________________________________________
> > Openmcl-devel mailing list
> > Openmcl-devel at clozure.com
> > http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel
> >
> >
>
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel
>
>
-------------- next part --------------
Index: lib/time.lisp
===================================================================
RCS file: /usr/local/publiccvs/ccl/lib/time.lisp,v
retrieving revision 1.4
diff -u -r1.4 time.lisp
--- lib/time.lisp	15 Jan 2002 23:43:37 -0000	1.4
+++ lib/time.lisp	19 Sep 2002 19:50:42 -0000
@@ -47,13 +47,23 @@
     (#_gettimeofday tv (%null-ptr))
     (+ (pref tv :timeval.tv_sec) unix-to-universal-time)))
 
+;;; This should stop using #_localtime: not all times can be represented
+;;; as a 32-bit offset from the start of Unix time, and (more importantly)
+;;; #_localtime isn't reentrant.
+;;; For now, if the time won't fit in 32 bits, use an arbitrary time
+;;; value to get the time zone and assume that DST was -not- in effect.
 (defun get-timezone (time)
-  (rlet ((when :long))
-    (setf (%get-long when) time)
-    (without-interrupts			;reentrancy ?
-     (with-macptrs ((ltm (#_localtime when)))
-       (values (floor (pref ltm :tm.tm_gmtoff) -60)
-	       (not (zerop (pref ltm :tm.tm_isdst))))))))
+  (let* ((toobig (not (or (typep time '(unsigned-byte 32))
+			  (typep time '(signed-byte 32))))))
+    (when toobig
+      (setq time 0))
+    (rlet ((when :long))
+      (setf (%get-long when) time)
+      (without-interrupts			;reentrancy ?
+       (with-macptrs ((ltm (#_localtime when)))
+	 (values (floor (pref ltm :tm.tm_gmtoff) -60)
+		 (unless toobig (not (zerop (pref ltm :tm.tm_isdst))))))))))
+
 
 (defun decode-universal-time (universal-time &optional time-zone)
   "Converts a universal-time to decoded time format returning the following


More information about the Openmcl-devel mailing list