Skip to content

Instantly share code, notes, and snippets.

@mytrile
Created September 12, 2012 14:08
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 mytrile/3917ad97e498e4c0dd78 to your computer and use it in GitHub Desktop.
Save mytrile/3917ad97e498e4c0dd78 to your computer and use it in GitHub Desktop.
{
"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"
}
}
(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