Comment detail

n日後を返す関数を返す関数 (Nested Flatten)

This comment is reply for 1339 smeghead: 日付型というのは見つからなかったので、構...(n日後を返す関数を返す関数). Go to thread root.

日付はuniversal-timeで持っておいて、日付用のformat関数を用意して、表示する時に変換する方が、らしい方法かもしれないと思いました。

(setq now (get-universal-time))
(date-format t now)
 => 2007/7/22 16:1:53
(date-format t (funcall (n-days-after 10) now))
 => 2007/8/1 16:1:53
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
(defun date-format (destination arg-date)
  (multiple-value-bind
    (second minute hour date month year)
    (decode-universal-time arg-date)
    (format destination "~d/~d/~d ~d:~d:~d"
            year month date hour minute second)))

(defun n-days-after (n)
  #'(lambda (arg-date) 
        (+ arg-date (* n 60 60 24))))

Index

Feed

Other

Link

Pathtraq

loading...