(in-package :cl-user)

(defparameter *zsofi-epoch* (encode-universal-time 0 0 0 28 11 2015)
  "Accurate only to the day.")

(defun days-old (month day &optional (year 2016))
  (/ (- (encode-universal-time 0 0 0 day month year) *zsofi-epoch*) 3600 24))

(defun days-old-when (n)
  (destructuring-bind (sec min hour date mon year &rest rest)
      (multiple-value-list
       (decode-universal-time (+ *zsofi-epoch* (* n 3600 24))))
    (declare (ignore sec min hour rest))
    (list year mon date)))

(defun days-old-now ()
  (destructuring-bind (sec min hour date mon year &rest rest)
      (multiple-value-list
       (decode-universal-time (get-universal-time)))
    (declare (ignore sec min hour rest))
    (/ (- (encode-universal-time 0 0 0 date mon year) *zsofi-epoch*) 3600 24)))

;;; (days-old 1 1)
;;; (days-old-when 100)
;;; (days-old-now)

#+nil
(sb-ext:run-program "/usr/bin/gnuplot" '("-e" "set xlabel 'Kor (nap)'; set ylabel 'Suly (g)'; plot '/home/salvi/blabla/zsofi-suly.txt' with lines notitle; pause mouse"))