X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=tests%2Ftime.lisp;h=24a3af205c0d9483497a687a106db3049d37d3f1;hb=218088774006bd9df58df318a6b3981065dfc71f;hp=410d14c8174e8006f4290eff0d27834e11a642b3;hpb=cc739f67940b866f1a3b963cd1f35d1c0c81dd0c;p=uffi.git diff --git a/tests/time.lisp b/tests/time.lisp index 410d14c..24a3af2 100644 --- a/tests/time.lisp +++ b/tests/time.lisp @@ -7,7 +7,7 @@ ;;;; Author: Kevin M. Rosenberg ;;;; Date Started: Feb 2002 ;;;; -;;;; $Id: time.lisp,v 1.3 2003/08/23 12:36:59 kevin Exp $ +;;;; $Id$ ;;;; ;;;; This file, part of UFFI, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; @@ -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,3 +94,15 @@ (zerop res2)))) t) +(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) + (asctime (gmtime time)))))) + +(deftest time.3 + (posix-time-to-asctime 0) + "Thu Jan 1 00:00:00 1970")