Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

workdays

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

workdays

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 07 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc