From 8085d5edf101e4f8a00834fc45783ad37d694e42 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Sat, 15 May 2004 17:06:04 +0000 Subject: [PATCH] r9363: fix time example, add new test --- debian/changelog | 6 ++++++ tests/time.lisp | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 11eabd9..e3eea13 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +cl-uffi (1.4.17-1) unstable; urgency=low + + * New upstream + + -- Kevin M. Rosenberg Sat, 15 May 2004 11:02:22 -0600 + cl-uffi (1.4.16-1) unstable; urgency=low * New upstream diff --git a/tests/time.lisp b/tests/time.lisp index aeedba0..24a3af2 100644 --- a/tests/time.lisp +++ b/tests/time.lisp @@ -32,10 +32,14 @@ ((time (* time-t))) :returning time-t) -(uffi:def-function ("gmtime" c-gmtime) +(uffi:def-function "gmtime" ((time (* time-t))) :returning (* tm)) +(uffi:def-function "asctime" + ((time (* tm))) + :returning :cstring) + (uffi:def-type time-t :unsigned-long) (uffi:def-type tm-pointer (* tm)) @@ -48,7 +52,7 @@ (deftest time.2 (uffi:with-foreign-object (time 'time-t) (setf (uffi:deref-pointer time :unsigned-long) 7381) - (let ((tm-ptr (the tm-pointer (c-gmtime time)))) + (let ((tm-ptr (the tm-pointer (gmtime time)))) (values (1+ (uffi:get-slot-value tm-ptr 'tm 'mon)) (uffi:get-slot-value tm-ptr 'tm 'mday) (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year)) @@ -90,13 +94,15 @@ (zerop res2)))) t) -(defun posix-time-to-localtime-string (secs) +(defun posix-time-to-asctime (secs) "Converts number of seconds elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC)" (string-right-trim '(#\newline #\return) (uffi:convert-from-cstring (uffi:with-foreign-object (time 'time-t) - (setf (uffi:deref-pointer time :unsigned-long) - secs) - (c-time time))))) + (setf (uffi:deref-pointer time :unsigned-long) secs) + (asctime (gmtime time)))))) +(deftest time.3 + (posix-time-to-asctime 0) + "Thu Jan 1 00:00:00 1970") -- 2.34.1