# n.el -rw-r--r-- 689 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
(defvar *ts* "%FT%T")
(defvar *pts* #'parse-iso8601-time-string)

(cl-defun n (&key (h 0) (m 0) (s 0) (yy 0) (mm 0) (dd 0) (ts *ts*) (fn *pts*))
  (cl-destructuring-bind (second minute hour day month year weekday dst zone)
      (decoded-time-add
       (decode-time (funcall fn (format-time-string ts)))
       (make-decoded-time
        :second s
        :minute m
        :hour   h
        :day   dd
        :month mm
        :year  yy))
    (format "%02d-%02d-%02dT%02d:%02d:%02d" year month day hour minute second)))

(n) ;; => "2026-01-04T18:04:07"
(n :h 4) ;; => "2026-01-04T22:04:08"
(n :h (* 24 -4)) ;; => "2025-12-31T18:04:33"
(n :yy -4 :h 24 :mm -3) ;; => "2022-10-05T18:05:26"