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

holiday

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

holiday

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Holiday

Holiday is a gem that lets you configure holidays for multiple countries with YAML.

Default Usage

First setup path to a YAML file and set the country code.


Holiday.yaml_file = "/path/to/yaml/holiday.yml"
Holiday.country = "US"

You can query for dates


# Defaults to current year
Holiday.find("christmas")
Holiday.find("labour day")

Or supply a year


# Can supply the year as optional argument
Holiday.find(:christmas, 2005)
Holiday.find(:thanksgiving, 1999)

YAML

The YAML format for Holiday is as follows

holiday:
  US:
    christmas:
      when: december 25th
      as: christmas
    halloween:
      when: october 31st
      as: halloween, all hallows eve
    labor_day:
      when: 1st monday in september
      as: labor day, labour day
    thanksgiving:
      when: 4th thursday in november
      as: thanksgiving, turkey day

Holidays are scoped by country code. Each holiday needs both "when" and "as" keys. The "when" key can either be an exact month and day, or the occurrence of the holiday in the given month. E.g., "1st monday in september".

The "as" key is used to identify holidays by alternate names and spellings. For instance, "thanksgiving" and "turkey day" should both point to the 4th thursday in november.


Holiday.find("turkey day")
Holiday.find(:thanksgiving)

Other methods

There are a few other methods that may be useful


Holiday.all # array containing all keys and alternate names of holidays from yaml file
Holiday.scan("a string containing a holiday by name, like christmas") # => christmas
Holiday::Query.find("all hallows eve") # => october 31st

FAQs

Package last updated on 12 Sep 2011

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