Last active
May 31, 2022 19:13
-
-
Save muihlinn/4136f92d9c52c41d8798d7ddfe0900b9 to your computer and use it in GitHub Desktop.
elisp last monday date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun muihlinn-last-monday() | |
"Date of last monday." | |
(let* ( (date (calendar-current-date)) | |
(today (calendar-absolute-from-gregorian date)) | |
(dow (calendar-day-of-week date))) | |
(cl-destructuring-bind (month day year) | |
(calendar-gregorian-from-absolute | |
;; if sunday and our weeks starts on monday | |
(if (and (eq dow 0) (eq calendar-week-start-day 1)) | |
(- today 6) | |
(1+ (- today dow)))) | |
(format "%04d-%02d-%02d" year month day)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment