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

holidayjs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

holidayjs

Holiday generator

  • 0.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
21
decreased by-51.16%
Maintainers
1
Weekly downloads
 
Created
Source

holidayjs

This is a holiday generator with heavy inspiration from holidayapi.com (https://github.com/joshtronic/holidayapi.com)

how to use

var holidayjs = require('holidayjs')('<path to your data files>')

holidayjs.calculateHolidays('ca', 2015, function(err, holidays) {
  //do stuff with the holidays
})

holiday outputted format

[{
  name: 'Halloween',
  date: '2015-10-31'
},{
  name: 'Christmas',
  date: '2015-12-25'
}, ...]

data file format

[{
  name: '<some name>',
  rule: {
    override: '', //use if you have a specific date in mind, ie. 'January 1'
    generator: {
      special: '', //use to base date relatively off a special date. accepted values are %EASTER
      day: {
        day: '', //use to specify day of the week, ie. 'Monday'
        placement: 1 //use to relatively choose the day of the week. possible values are -1, -2, -3, -4, 1, 2, 3, 4
      },
      month: 'september', //use to specify month, ie. 'September'
      modifier: '+3 days' //use to offset the date by some amount
    },
    ifWeekend: { //if the date eventually lands on a weekend...
      pushTo: 'Monday' //push it to the specified day here
    }
  }
  }
}, {}, ...]

data file sample

module.exports = [
  {
    name: 'New Year\'s Day',
    rule: {
      override: 'January 1'
    }
  }, { 
    name: 'Family Day',     
    rule: {
      generator: {
        day: {
          day: 'Monday',
          placement: 3
        },
        month: 'February'
      }
    }
  }, { 
    name: 'Good Friday',     
    rule: {
      generator: {
        special: '%EASTER',
        modifier: '-2 days'
      }
    }
  }, { 
    name: 'Victoria Day',    
    rule: {
      generator: {
        day: {
          day: 'Monday',
          placement: 3
        },
        month: 'May'
      }
    }
  }, {
    name: 'Canada Day',
    rule: {
      override: 'July 1' 
    }
  }, { 
    name: 'Labor Day',
    rule: {
      generator: {
        day: {
          day: 'Monday',
          placement: 1
        },
        month: 'September'
      }
    }
  }, { 
    name: 'Thanksgiving',
    rule: {
      generator: {
        day: {
          day: 'Monday',
          placement: 2
        },
        month: 'October'
      }
    }
  }, {
    name: 'Remembrance Day',
    rule: {
      generator: {
        day: {
          day: 'Monday',
          placement: 2
        },
        month: 'October'
      }
    }
  }, {
    name: 'Christmas',
    rule: {
      override: 'December 25'
    }
  }
]

FAQs

Package last updated on 05 May 2016

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