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

holidate

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

holidate

  • 1.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Holidate

A simple gem that returns Date objects for holidays

Usage

Currently has methods to find the 10 US federal holidays, with year as an optional argument that defaults to the current year.

Holidate.new_years_day              # alias: new_year
Holidate.martin_luther_king_jr_day  # alias: mlk
Holidate.washingtons_birthday       # alias: washington
Holidate.memorial_day               # alias: memorial
Holidate.independence_day           # alias: july_4
Holidate.labor_day                  # alias: labor
Holidate.columbus_day               # alias: columbus
Holidate.veterans_day               # alias: veteran
Holidate.thanksgiving_day           # alias: thanksgiving
Holidate.christmas_day              # alias: xmas

Also has a ::find method that allows you to find the nth day of the week in a given month and year.

Holidate.find('1st', 'Friday', 'December', '1985')

You can also find the nth to last day.

Holidate.find(:third_to_last, :wed , :oct, :'2013')

::find is case-insensitive and accepts both strings and symbols. It also accepts abbreviations for months and days of the week and allows first, second, etc. to be abbreviated as 1st, 2nd, etc. You can also give ::find integers. Day of the week and month should correspond to Date#wday and Date#month, respectively.

Holidate.find(-1, 0, 7, 1985) # == Holidate.find('last', 'Sunday', 'July', '1985')

Of course, magic numbers can make code harder to understand, so use with caution.

FAQs

Package last updated on 19 Mar 2015

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