Skip to content

Instantly share code, notes, and snippets.

@KirinDave
Created January 23, 2010 00:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save KirinDave/198e96fbdf697b98d3d3 to your computer and use it in GitHub Desktop.
(def interval-patterns {
:second [(gen-intregexp "?(s|secs?|seconds?)") 1]
:minute [(gen-intregexp "?(m|mins?|minutes?)") 60]
:hour [(gen-intregexp "?(h|hours?|hr)") 3600]
:day [(gen-intregexp "?(d|days?)") 86400]
:year [(gen-intregexp "?(y|years?)") 31536000]})
(defmacro- pat-m [k] ((k interval-patterns) 0))
(defmacro- sec-m [k] ((k interval-patterns) ))
; This seems to work from the command line but fails with "No message" on module load if used in expressions. Macroexpand-1 suggests it does what I expect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment