Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

holiday is a package to generate holiday.

Project Description

Judgment whether the holiday

Requiremants

  • Python 2.7 or later.

Install

$ pip install holiday

holiday format

('*', '*', '*', '*', '*')
  ┬    ┬    ┬    ┬    ┬
  │    │    │    │    │
  │    │    │    │    │
  │    │    │    │    └─  number of week (1 - 5)
  │    │    │    └─── day of week (1 to 7 or mon to sun)
  │    │    └───── day of month (1 - 31)
  │    └─────── month (1 - 12)
  └───────── year (1 - 9999)

'*' The asterisk allows all

Usage

>>> holiday = Holiday([
...     (2016, 1, 1, 'fri', 1),
...     (2016, 1, 2, 'sat', 1),
... ])

>>> holiday.is_holiday(date(2016, 1, 1))  # 2016-1-1 Friday 1
True
>>> holiday.is_holiday(date(2016, 1, 3))  # 2016-1-3 Sunday 1
False
  • Express all values that can take in the field in asterisk (*)
>>> holiday = Holiday([
...     ('*', 1, 1, 'fri', 1),
...     ('*', 1, 1, 'thu', 1),
... ])

>>> holiday.is_holiday(date(2016, 1, 1))  # 2016-1-1 Friday 1
True
>>> holiday.is_holiday(date(2015, 1, 1))  # 2015-1-1 Thursday 1
True
>>> holiday.is_holiday(date(2014, 1, 1))  # 2014-1-1 Wednesday 1
False
  • is_business_day() returns the inverse of the truth-value of the is_holiday()
>>> holiday = Holiday([
...     ('*', '*', '*', '*', '*'),
... ])

>>> holiday.is_holiday(date(2016, 1, 1))  # 2016-1-1 Friday 1
True
>>> holiday.is_business_day(date(2016, 1, 1))  # 2016-1-1 Friday 1
False

License

This software is released under the MIT License, see LICENSE.txt.

Release History

Release History

This version
History Node

1.0.0

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
holiday-1.0.0-py2.py3-none-any.whl (6.0 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Mar 5, 2016
holiday-1.0.0.tar.gz (5.4 kB) Copy SHA256 Checksum SHA256 Source Mar 5, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting