Skip to content

Instantly share code, notes, and snippets.

@tangrammer
Created September 20, 2016 09:09
Show Gist options
  • Select an option

  • Save tangrammer/d8133a3b35f0cf0d2b34c5753fdfd982 to your computer and use it in GitHub Desktop.

Select an option

Save tangrammer/d8133a3b35f0cf0d2b34c5753fdfd982 to your computer and use it in GitHub Desktop.
example of getting errors using LP and CIDER

Namespace: funicular.time

so far the fns for retrieving data regarding days and months for current year

(ns funicular.time
  (:require [clj-time.predicates :as p]
            [clj-time.core :as t]))

(defn now []
  (t/now))


(t/day-of-week (now))



(t/plus (t/date-time 2016 1 1) (t/days 1))


(p/sunday? (now))

Fns

Days-in-month

months are integers indexed from 1 to 12 years are common years integers

(defn days-in-month [year month]
  (t/number-of-days-in-the-month year month))

(days-in-month 2016 12)

Sundays

(defn sundays [year month]
  (let [limit (t/number-of-days-in-the-month year month)]
    (filter some? (for [a (range 1 limit)]
       (when (p/sunday? (t/date-time year month a))
         a)))))

(sundays 2016 12)
#'funicular.time/days-in-month31
(now)

#object[org.joda.time.DateTime 0x679b5045 "2016-09-19T09:52:21.122Z"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment