Swift library for german holidays
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
SSHolidays.xcodeproj
SSHolidays
SSHolidaysTests
LICENSE
README.md
SSHolidays.podspec

README.md

SSHolidays

Swift library for eastern and all german and austrian holidays (fixed to states and not).

##Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like SSHolidays in your projects.

$ gem install cocoapods

###Podfile

To integrate SSHolidays into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
pod 'SSHolidays', '1.0'
end

Then, run the following command:

$ pod install

##Architecture

###Holidays

  • holidays
  • isHolidayByDate
  • isHolidayByComponents
  • holidaysBetweenDates

###Holiday

  • name
  • year
  • month
  • day
  • date
  • fixedWithState
  • states
  • weekday

##Usage

First you need to import the main class:

import SSHolidays

###Holiday

####name A String representing the holiday's name. This is mostly in english, but all german holidays are in german for obvious reasons. ####year Intrepresenting the holiday's year. ####month Intrepresenting the holiday's month. ####day Intrepresenting the holiday's day. ####date NSDaterepresenting the holiday's date as a NSDate object. ####fixedWithState Boolrepresenting if a holiday is fixed to a german state. ####states Array<String>containing all states fixed to this holiday (empty if non fixed) ####weekday Intrepresenting the holiday's weekday.

###Holidays

All holiday functions have a country parameter, which currently only supports the following country Codes:

  • "de"for all german holidays
  • "at"for all austrian holidays

####holidaysBetweenDates To check if holidays are between two dates call Holidays.holidaysBetweenDates. This will return an Array containing Holiday Objects for the period you requested.

let date1 = NSDate()
        
let dateComponents: NSDateComponents = NSDateComponents()
dateComponents.year = 2016
dateComponents.month = 12
dateComponents.day = 30
let date2 :NSDate = NSCalendar.currentCalendar().dateFromComponents(dateComponents)!
        
let holidaysInBetween = Holidays.holidaysBetweenDates(country: "de", fromDate: date1, toDate: date2)

####holidays To check for holidays by year just call Holidays.holidays with the IntParameter for the requested year. This will return an Array containing Holiday Objects for the requested year.

let holidays2016 = Holidays.holidays(country: "de", year: 2016)

####isHolidayByDate To check wheater a certain date (by NSDate) is a holiday or not call Holidays.isHolidayByDate. This returns a boolean value.

 if Holidays.isHolidayByDate(country: "de", date: NSDate()) {
            print("This may be first christmas day")
  }

####isHolidayByComponents To check wheater a certain date (by date components) is a holiday or not call Holidays.isHolidayByComponents. This returns a boolean value.

 if Holidays.isHolidayByComponents(country: "de", year: 2016, month: 12, day: 25) {
            print("This is first christmas day")
  }

##License

SSHolidays is released under the MIT license. See LICENSE for details.