Skip to content

Instantly share code, notes, and snippets.

@spacebat
Created April 21, 2013 03:46
Show Gist options
  • Select an option

  • Save spacebat/5428381 to your computer and use it in GitHub Desktop.

Select an option

Save spacebat/5428381 to your computer and use it in GitHub Desktop.
A bit of month transform code
(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