SSHolidays 1.0.3

SSHolidays 1.0.3

测试已测试
语言语言 SwiftSwift
许可证 MIT
发布上次发布2016年7月
SPM支持 SPM

Ralf Peters 维护。



  • 作者:
  • Ralf Peters

SSHolidays

Swift 库,用于处理东方和德国的节假日(固定到各州,而不是)。

Podfile

要使用 CocoaPods 将 SSHolidays 集成到您的 Xcode 项目中,请在 Podfile 中指定它

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

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

然后,运行以下命令

$ pod install

架构

节假日

  • 节假日
  • isHolidayByDate
  • isHolidayByComponents
  • holidaysBetweenDates

节假日

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

使用

首先您需要导入主类

import SSHolidays

节假日

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.

节假日

holidaysBetweenDates

要检查两个日期之间是否有假日,请调用 Holidays.holidaysBetweenDates。这将返回一个包含您请求期间 Holiday 对象的数组。

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(fromDate: date1, toDate: date2)

holidays

要检查某一年份的假日,只需调用 Holidays.holidays 并传递请求年份的 Int 参数。这将返回一个包含请求年份 Holiday 对象的数组。

let holidays2016 = Holidays.holidays(year: 2016)

isHolidayByDate

要检查某个特定日期(通过 NSDate)是否为假日,请调用 Holidays.isHolidayByDate。这将返回一个布尔值。

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

isHolidayByComponents

要检查某个特定日期(通过日期组件)是否为假日,请调用 Holidays.isHolidayByComponents。这将返回一个布尔值。

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

许可证

SSHolidays 在 MIT 许可证下发布。有关详细信息,请参阅 LICENSE。