Skip to content

polygloton/calendar-logic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calendar-logic

This is a calendar library for Clojure that uses core.logic. You can create interesting queries against the Gregorian calendar. (In the future I hope to add the ability to build queries that involve multiple calendars).

Usage

Here are some examples, and there are many more in the tests.

Find months in 2013 where Friday falls on the 13th

(use 'clojure.core.logic)
(use 'datetime-logic.gregorian)

(run* [month]
  (day-of-the-week 2013 month 13 :friday))

Results in (9 12).

What day is Thanksgiving (US) in 2013?

(use 'clojure.core.logic)
(use 'datetime-logic.us-holidays)

(run* [day]
  (thanksgiving-day 2013 11 day))

Results in (28).

Which federal holidays (US) are on Monday in 2013?

(use 'clojure.core.logic)
(use 'datetime-logic.us-holidays)
(use 'datetime-logic.gregorian)

(run* [holiday]
  (fresh [month day]
    (federal-holiday 2013 month day holiday)
    (day-of-the-week 2013 month day :monday)))

Results in (:mlk-bday :washington-bday :veterans-day :memorial-day :labor-day :columbus-day), which is only really interesting because it includes veterans day (defined as Nov 11th rather than a Monday).

Inspiration

These are the inspirations influencing this project.

  • The Reasoned Schemer Taught me relational programming
  • Calendrical Calculations Provides an algorithmic explanation of thirty calendars.
  • The many lectures of David Nolen, Daniel Friedman and William Byrd.
  • The Clojure/West 2013 miniKanren Confo.

License

Copyright © 2013-2014 Stephen Sloan

Distributed under the Eclipse Public License, the same as Clojure.

About

datetime-logic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors