Workdays
A hard-working collection of methods to make calculating working dates easier.
This gem provides a number of convenience methods to simplify calculating dates while respecting non-working days. Uses the Holiday gem so that holiday schedules can be localized and customized.
Installation
Add this line to your application's Gemfile:
gem "workdays"
And then execute:
$ bundle
Or install it yourself as:
$ gem install workdays
Usage
By default, Workdays will use :ca
as the default locale.
Date.new(2017, 2, 8) .workday?
Date.new(2017, 12, 25).workday?
fri_before_family_day = Date.new(2016, 2, 12)
family_day = Date.new(2016, 2, 15)
tues_after_family_day = Date.new(2016, 2, 16)
family_day.workday?(:ca_on)
family_day.workday?(:ca_qc)
tues_after_family_day.last_workday(:ca_on)
tues_after_family_day.last_workday(:ca_qc)
tues_after_family_day.workdays_before(1, :ca_on)
tues_after_family_day.workdays_before(1, :ca_qc)
tues_after_family_day.workdays_after(-1, :ca_qc)
fri_before_family_day.workdays_after(1, :ca_on)
fri_before_family_day.workdays_after(1, :ca_qc)
Workdays.workdays_in(fri_before_family_day, family_day, :ca_on)
Workdays.workdays_in(fri_before_family_day, family_day, :ca_qc)
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/julienroger/workdays.
License
MIT
Copyright (c) 2017 Julien Roger