X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=logger.lisp;h=d35708b6c540e3783c9ffabd35011a7fb190833f;hb=69e24d396d159da6778fc4ae9446e084f7304758;hp=449f154a08e97c76b37f1e0c0e4c43b87347b252;hpb=bf7cb3143da8886c3671d2ce007487b0a93ebbcd;p=irc-logger.git diff --git a/logger.lisp b/logger.lisp index 449f154..d35708b 100644 --- a/logger.lisp +++ b/logger.lisp @@ -246,10 +246,11 @@ (format stream "~S~%" (string-right-trim '(#\return) (raw-message-string msg))))) -(uffi:def-foreign-type time-t :unsigned-long) -(uffi:def-function ("ctime" c-ctime) - ((time (* time-t))) - :returning :cstring) +(defconstant +posix-epoch+ + (encode-universal-time 0 0 0 1 1 1970 0)) + +(defun posix-time-to-utime (time) + (+ time +posix-epoch+)) (defun last-sexp-field (type msg) (cond @@ -261,11 +262,7 @@ (when (stringp (car (last (arguments msg)))) (let ((secs (parse-integer (car (last (arguments msg))) :junk-allowed t))) (when secs - (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-ctime time)))))))) + (posix-time-to-utime secs))))) ((need-user-address? type) (user-address msg))))