Project

workdays

0.0
No commit activity in last 3 years
No release in over 3 years
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.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 1.13
~> 12.0
~> 3.6
~> 0.49

Runtime

 Project Readme

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? # => true
Date.new(2017, 12, 25).workday? # => false

fri_before_family_day = Date.new(2016, 2, 12) # Fri, 12 Feb 2016
family_day            = Date.new(2016, 2, 15) # Mon, 15 Feb 2016
tues_after_family_day = Date.new(2016, 2, 16) # Tue, 16 Feb 2016

family_day.workday?(:ca_on)                       # => false
family_day.workday?(:ca_qc)                       # => true

tues_after_family_day.last_workday(:ca_on)        # => Fri, 12 Feb 2016
tues_after_family_day.last_workday(:ca_qc)        # => Mon, 15 Feb 2016
tues_after_family_day.workdays_before(1, :ca_on)  # => Fri, 12 Feb 2016
tues_after_family_day.workdays_before(1, :ca_qc)  # => Mon, 15 Feb 2016
tues_after_family_day.workdays_after(-1, :ca_qc)  # => Mon, 15 Feb 2016

fri_before_family_day.workdays_after(1, :ca_on)   # => Tue, 16 Feb 2016
fri_before_family_day.workdays_after(1, :ca_qc)   # => Mon, 15 Feb 2016


Workdays.workdays_in(fri_before_family_day, family_day, :ca_on) # => 1
Workdays.workdays_in(fri_before_family_day, family_day, :ca_qc) # => 2

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/julienroger/workdays.

License

MIT

Copyright (c) 2017 Julien Roger