A simple library to check if a date is a holiday.
Add the following to your sbt build (Scala 2.12.x):
libraryDependencies += "com.github.sameerparekh" %% "holidays" % "0.1.1"
- Import the library.
- Configure an implicit holiday list (
HolidayList
) - Check your
LocalDate
to see if it is a holiday.
import com.github.sameerparekh.holidays._
import org.joda.time.LocalDate
implicit val holidayList: HolidayList = USAFederalHolidays
println {
if (LocalDate.now().isHoliday) "Today is a holiday"
else "Today is not a holiday"
}
Pull requests welcome.
- Create a new instance of a
HolidayFromYear
, which is a function from a year to aLocalDate
. A number of helper functions are available.
- Create a new instance of a
HolidayList
, which is a set ofHolidayFromYear
.