Created
September 29, 2021 15:00
-
-
Save juan-reynoso/1bdee3bd87c7bc729f9a234236ba8e92 to your computer and use it in GitHub Desktop.
Compare dates
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 date-compare (time-a time-b) | |
"Returns the symbols <, >, or =, describing the relationship between TIME-A and TIME-B." | |
(declare (type timestamp time-a time-b)) | |
(cond | |
((< (day-of time-a) (day-of time-b)) '<) | |
((> (day-of time-a) (day-of time-b)) '>) | |
(t '=))) | |
(defun date= (time-a time-b) | |
"Return T if date of TIME-A is equal to date of TIME-B, NIL otherwise." | |
(eql (date-compare time-a time-b) '=)) | |
(defun date> (time-a time-b) | |
"Return T if date of TIME-A is greater than date of TIME-B, NIL otherwise." | |
(eql (date-compare time-a time-b) '>)) | |
(defun date< (time-a time-b) | |
"Return T if date of TIME-A is less than date of TIME-B, NIL otherwise." | |
(eql (date-compare time-a time-b) '<)) | |
(defun date>= (time-a time-b) | |
"Return T if date of TIME-A is greater than or equal to date of TIME-B, NIL otherwise." | |
(not (null (member (date-compare time-a time-b) '(> =))))) | |
(defun date<= (time-a time-b) | |
"Return T if date of TIME-A is less than or equal to date of TIME-B, NIL otherwise." | |
(not (null (member (date-compare time-a time-b) '(< =))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment