-
-
Save mytrile/3917ad97e498e4c0dd78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"09": { | |
"01": "Some text for 09-01", | |
"02": "Some text for 09-02", | |
"03": "Some text for 09-03", | |
"11": "Some text for 09-11" | |
}, | |
"10": { | |
"01": "Some text for 10-01", | |
"02": "Some text for 10-02" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns some.core | |
(:use [clj-time.local]) | |
(:use [clojure.data.json]) | |
(:use [clojure.java.io]) | |
(:use [clojure.string :only [split]])) | |
(def parse-date | |
(let [date (drop 1 (split (format-local-time (local-now) :date) #"-")) | |
month (first date) | |
day (last date)] | |
[month day])) | |
(def load-json | |
(read-json (reader "resources/calendar.json"))) | |
(def get-data-from-json | |
(let [day (keyword (first parse-date)) | |
month (keyword (last parse-date))] | |
(-> load-json month day))) | |
;; Assuming that today is 2012-09-12 | |
;; get-data-from-json => Some text for 10-01 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment