Finish minari-today-string

This commit is contained in:
Gergely Polonkai 2016-11-10 19:13:08 +01:00
parent 2dd0f9edf2
commit 30ec3aad97

View File

@ -23,9 +23,10 @@
(defun minari-today-string ()
"Calculate today's date according to the Minari Calendar."
(let ((today (decode-time (current-time))))
(message "%s" today)
(setf (nth 3 today) (+ (nth 3 today) 11))
(message "%s" today)
;; FIXME: Im not sure about this one… If I increment by 11, I get a
;; wrong date according to my GNOME Shell extension. If I increment by
;; 10, the date is OK, but by calculating it in my head, its bad.
(incf (nth 3 today) 10)
(let* ((minari-leap (date-leap-year-p (nth 5 today)))
(doy (time-to-day-in-year (apply 'encode-time today)))
(minari-year (- (nth 5 today) 1873))
@ -45,20 +46,24 @@
((and (eq doy 365) minari-leap) (setq minari-special-day 5))
(t (let ((decr 0)
(minari-doy doy))
(when (> minari-doy 0) (setq decr (1+ decr)))
(when (> minari-doy 91) (setq decr (1+ decr)))
(when (> minari-doy 182) (setq decr (1+ decr)))
(when (and (> minari-doy 183) minari-leap) (setq decr (1+ decr)))
(when (and (> minari-doy 273) (not minari-leap))
(setq decr (1+ decr)))
(when (and (> minari-doy 274) minari-leap) (setq decr (1+ decr)))
(setq minari-doy (- minari-doy (1+ decr))
minari-month (round (fceiling (/ minari-doy 30)))
(when (> minari-doy 0) (incf decr))
(when (> minari-doy 91) (incf decr))
(when (> minari-doy 182) (incf decr))
(when (and (> minari-doy 183) minari-leap) (incf decr))
(when (and (> minari-doy 273) (not minari-leap)) (incf decr))
(when (and (> minari-doy 274) minari-leap) (incf decr))
(setq minari-doy (- minari-doy (- decr 1))
minari-month (round (fceiling (/ minari-doy 30.0)))
minari-day (% minari-doy 30))
(when (eq minari-day 0) (setq minari-day 30))
(setq minari-weekday (% minari-day 6)))))
(message "%d %s %s" minari-year minari-month minari-day)
)))
(when (eq minari-day 0) (setq minari-day 30))
(setq minari-weekday (% minari-day 6)))))
(if (eq -1 minari-special-day)
(format "%d %s %s (%s)"
minari-year
(nth (- minari-month 1) minari-month-names)
minari-day
(nth minari-weekday minari-weekday-names))
(nth (- minari-special-day 1) minari-special-day-names)))))
(provide 'minari)