Git Product home page Git Product logo

google-calendar-holiday's Introduction

travis-ci

Google Calendar Helper

Use Google Calendar API v3 to

  • check if a date is holiday
  • get holiday names of a given date

with a given list of publicly available calendars

Installation

npm install --save google-calendar-holiday

Set up your credentials and Google Calendar

Enable Google Calendar API https://developers.google.com/calendar/quickstart/nodejs

Create an API key in Credentials page

Examples

Init

const GoolgeCalendarHoliday = require('google-calendar-holiday');
const holiday = new GoolgeCalendarHoliday(
  'API_KEY',
  {
    hkHoliday: 'zh-tw.hong_kong%23holiday%40group.v.calendar.google.com',
    usHoliday: 'en.usa%23holiday%40group.v.calendar.google.com',
  },
);
// this will try to make an API call to test if the API key is valid
await holiday.init();

Check whether a date is holiday

holiday.isHoliday('2018-10-17') // true
holiday.isHoliday('2018-11-22') // true

// specify calendars
holiday.isHoliday('2018-10-17', ['hkHoliday']) // true
holiday.isHoliday('2018-11-22', ['hkHoliday']) // false

Get holiday names of a date

holiday.getHolidayNames('2018-10-17') // ['重陽節']
holiday.getHolidayNames('2018-11-22') // ['Thanksgiving Day']
holiday.getHolidayNames('2018-01-01') // ['元旦', 'New Year's Day']

// specify calendars
holiday.getHolidayNames('2018-10-17', ['hkHoliday']) // ['重陽節']
holiday.getHolidayNames('2018-11-22', ['hkHoliday']) // ['']

google-calendar-holiday's People

Contributors

cklll avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.