diff options
Diffstat (limited to 'src/utils.clj')
| -rwxr-xr-x | src/utils.clj | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/utils.clj b/src/utils.clj index 4ed446a..1bccb09 100755 --- a/src/utils.clj +++ b/src/utils.clj @@ -131,16 +131,16 @@ (def yyyy-formatter (new SimpleDateFormat "yyyy")) (def yyyy-mm-formatter (new SimpleDateFormat "yyyy-MM")) (def yyyy-mm-dd-formatter (new SimpleDateFormat "yyyy-MM-dd")) -(def yymmdd-formatter (new SimpleDateFormat "yyyyMMdd")) +(def yyyymmdd-formatter (new SimpleDateFormat "yyyyMMdd")) -(doseq [f [yyyy-formatter yyyy-mm-formatter yyyy-mm-dd-formatter yymmdd-formatter]] +(doseq [f [yyyy-formatter yyyy-mm-formatter yyyy-mm-dd-formatter yyyymmdd-formatter]] (.setLenient f false)) (defn format-yyyy-mm-dd [d] (.format yyyy-mm-dd-formatter d)) (defn format-yyyymmdd [d] - (.format yymmdd-formatter d)) + (.format yyyymmdd-formatter d)) (defn today [] (format-yyyymmdd (new Date))) @@ -188,6 +188,12 @@ (.setTimeZone df (TimeZone/getTimeZone "GMT")) (.format df dt)))) +(defn advance-date [dt i] + (let [c (java.util.Calendar/getInstance)] + (.setTime c dt) + (.add c java.util.Calendar/DATE i) + (.getTime c))) + ;; JSON responses (defmethod print-json Date @@ -352,6 +358,10 @@ (defn parse-yyyy-mm-dd-date [s] (try (.parse yyyy-mm-dd-formatter s) (catch java.text.ParseException _ nil))) + +(defn parse-yyyymmdd-date [s] + (try (.parse yyyymmdd-formatter s) + (catch java.text.ParseException _ nil))) (defn parse-flexi-date "Accepts date strings as YYYY, YYYY-MM, or YYYY-MM-DD." |
