Created
April 21, 2013 03:46
-
-
Save spacebat/5428381 to your computer and use it in GitHub Desktop.
A bit of month transform code
This file contains hidden or 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
| (setq month-names '("January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December")) | |
| (setq month-names-to-numbers (loop for name in month-names for number from 1 collect (cons name number))) | |
| (defun month-name-to-number (name) | |
| (or (cdr (assoc name month-names-to-numbers)) | |
| (error "Month not recognized: '%s'" name))) | |
| (defun month-name-to-number-nice (name) | |
| (let ((number (month-name-to-number name))) | |
| (format "%02d" number))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment