GoogleHolidayCalendar
Get holidays via Google Calendar.
Requirements
Installation
Add this line to your application's Gemfile:
gem 'google_holiday_calendar'
And then execute:
$ bundle
Or install it yourself as:
$ gem install google_holiday_calendar
Getting API key
1. Create GCP project
https://console.cloud.google.com/projectcreate
2. Go to credentials
3. Create credential with API key
4. Enable restrictions (Optional)
Click RESTRICT KEY
e.g. "IP addresses" in Application restrictions
5. Enable calendar API
Go to Library
Search with "Calendar" and enable "Google Calendar API".
Usage (via ruby)
require "google_holiday_calendar"
usa_calendar = GoogleHolidayCalendar::Calendar.new(country: "usa", lang: "en", api_key: "YOUR_API_KEY")
usa_calendar.holidays(start_date: "2014-01-01", end_date: "2014-03-01", limit: 5)
japan_calendar = GoogleHolidayCalendar::Calendar.new(country: "japanese", lang: "ja", api_key: "YOUR_API_KEY")
japan_calendar.holidays(start_date: "2014-01-01", end_date: "2014-03-01", limit: 5)
japan_calendar.holiday?("2014-01-01")
japan_calendar.holiday?("2014-02-01")
Usage (via bash)
$ date +"%Y-%m-%d"
2014-02-24
$ GOOGLE_API_KEY=xxxx google_holiday_calendar
2014-03-09: Daylight Saving Time starts
$ GOOGLE_API_KEY=xxxx google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01
2014-01-01: New Year's Day
2014-01-20: Martin Luther King Day
2014-02-14: Valentine's Day
2014-02-17: Presidents' Day (Washington's Birthday)
2014-03-09: Daylight Saving Time starts
2014-04-13: Thomas Jefferson's Birthday
2014-04-20: Easter Sunday
2014-05-11: Mothers' Day
2014-05-26: Memorial Day
2014-06-15: Fathers' Day
$ GOOGLE_API_KEY=xxxx google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01 --limit=3
2014-02-14: Valentine's Day
2014-02-17: Presidents' Day (Washington's Birthday)
2014-04-13: Thomas Jefferson's Birthday
$ GOOGLE_API_KEY=xxxx google_holiday_calendar --start-date=2014-01-01 --end-date=2014-07-01 --country=japanese --lang=ja
2014-01-01: 元日
2014-01-02: 銀行休業日
2014-01-03: 銀行休業日
2014-01-13: 成人の日
2014-02-11: 建国記念の日
2014-03-21: 春分の日
2014-04-29: 昭和の日
2014-05-03: 憲法記念日
2014-05-04: みどりの日
2014-05-06: みどりの日 振替休日
More reference
http://rubydoc.info/github/sue445/google_holiday_calendar
Contributing
- Fork it ( http://github.com/sue445/google_holiday_calendar/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request