summaryrefslogtreecommitdiff
path: root/src/utils.clj
diff options
context:
space:
mode:
authorScott Ostler <scottbot9000@gmail.com>2011-02-23 00:06:37 -0500
committerScott Ostler <scottbot9000@gmail.com>2011-02-23 00:06:37 -0500
commit9da44d38f552388680c47ad592edeb2b114d67d4 (patch)
tree4700f141f408c9dfa11072df635a89d631032930 /src/utils.clj
parent21ec2e9244ef0787908aede4bf4cb2e94bcf395d (diff)
add selector for frontpage
Diffstat (limited to 'src/utils.clj')
-rwxr-xr-xsrc/utils.clj16
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."