Tweak to edit post form layout
[lw2-viewer.git] / src / utils.lisp
blobfbd2185dbf73404ee101b9c5f107a1aac1ed54fa
1 (uiop:define-package #:lw2.utils
2 (:use #:cl)
3 (:export #:alist #:get-unix-time #:substring #:to-boolean #:map-plist)
4 (:recycle #:lw2-viewer))
6 (in-package #:lw2.utils)
8 (declaim (inline alist))
9 (defun alist (&rest parms) (alexandria:plist-alist parms))
11 (defun get-unix-time ()
12 (- (get-universal-time) #.(encode-universal-time 0 0 0 1 1 1970 0)))
14 (deftype array-dimension-type () `(integer 0 ,(- array-dimension-limit 1)))
16 (declaim (inline substring)
17 (ftype (function (string array-dimension-type &optional array-dimension-type) string) substring))
18 (defun substring (string start &optional (end (length string)))
19 (make-array (- end start) :element-type 'character :displaced-to string :displaced-index-offset start))
21 (declaim (inline to-boolean))
22 (defun to-boolean (value)
23 (and value t))
25 (defun map-plist (fn plist)
26 (loop for (key val . rest) = plist then rest
27 while key
28 nconc (funcall fn key val)))