Skip to content

Instantly share code, notes, and snippets.

@ezmiller
Created December 29, 2020 18:50
Show Gist options
  • Save ezmiller/e642960d4653f0c8a54ca15d2fd5e041 to your computer and use it in GitHub Desktop.
Save ezmiller/e642960d4653f0c8a54ca15d2fd5e041 to your computer and use it in GitHub Desktop.
Clojure lazy sequence of days from 1970-01-01 using java.time
;; Creates a lazy sequence of days from 1970-01-01
(defn days-from-epoch
([] (days-from-epoch (java.time.LocalDate/parse "1970-01-01")))
([local-date]
(prn local-date)
(lazy-seq (cons local-date (days-from-epoch (.plusDays local-date 1))))))
(take 2 (days-from-epoch))
;; => (#time/date "1970-01-01" #time/date "1970-01-02")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment