1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
6 ;;;; Purpose: UFFI Example file to get time
7 ;;;; Programmer: Kevin M. Rosenberg
8 ;;;; Date Started: Mar 2002
10 ;;;; Copyright (c) 2002 Kevin M. Rosenberg
12 ;;;; $Id: gettime.cl,v 1.4 2002/03/10 22:29:47 kevin Exp $
14 ;;;; This file is part of UFFI.
16 ;;;; UFFI is free software; you can redistribute it and/or modify
17 ;;;; it under the terms of the GNU General Public License (version 2) as
18 ;;;; published by the Free Software Foundation.
20 ;;;; UFFI is distributed in the hope that it will be useful,
21 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;;; GNU General Public License for more details.
25 ;;;; You should have received a copy of the GNU General Public License
26 ;;;; along with UFFI; if not, write to the Free Software Foundation, Inc.,
27 ;;;; 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 ;;;; *************************************************************************
32 (uffi:def-type time-t :unsigned-long)
45 (uffi:def-function ("time" c-time)
49 (uffi:def-function ("localtime" c-localtime)
54 "Returns the local time"
55 (let* ((time (uffi:allocate-foreign-object time-t)))
56 ;; (uffi:uffi-declare time-t time)
58 (let ((tm-ptr (c-localtime time)))
59 ;; (uffi:uffi-declare (* tm) tm-ptr)
60 (let ((time-string (format nil "~2d/~2,'0d/~d ~2d:~2,'0d:~2,'0d"
61 (1+ (uffi:get-slot-value tm-ptr 'tm 'mon))
62 (uffi:get-slot-value tm-ptr 'tm 'mday)
63 (+ 1900 (uffi:get-slot-value tm-ptr 'tm 'year))
64 (uffi:get-slot-value tm-ptr 'tm 'hour)
65 (uffi:get-slot-value tm-ptr 'tm 'min)
66 (uffi:get-slot-value tm-ptr 'tm 'sec)
68 (uffi:free-foreign-object time)
73 (format t "~&~A" (gettime))