Skip to content

Instantly share code, notes, and snippets.

@sritchie
Created February 3, 2011 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sritchie/9363935ac77cc8ef2f5a to your computer and use it in GitHub Desktop.
Save sritchie/9363935ac77cc8ef2f5a to your computer and use it in GitHub Desktop.
(defmulti julian->period
"Converts a given input date into an interval from the MODIS
beginnings, as specified by modis-start. Accepts DateTime objects,
strings that can be coerced into dates, or an arbitrary number of
integer pieces. See clj-time's date-time and from-string for more
information."
(fn [x & _] (type x)))
(defmethod julian->period DateTime
[date]
(in-periods (interval modis-start date)))
(defmethod julian->period String
[str]
(julian->period (from-string str)))
(defmethod julian->period Integer
[& int-pieces]
(julian->period (apply date-time int-pieces)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment