DateOfEaster 1.2.0

DateOfEaster 1.2.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2018
SPMSupports SPM

Maintained by Michał Nierebiński.



DateOfEaster

Swift 4.1 Build StatusCode coverage status Code climate Codacy Badge codebeat badge CocoaPods Compatible Platform

Supported Swift version: Swift 4.1+

Supported platforms: iOS 9.0+, macOS 10.9+, tvOS 10.0+, watchOS 3.0, Ubuntu 14+

Introduction

DateOfEaster is an extension for the Date class, used for calcutation of Easter date, both western (used by Roman Catholic Church and many protestant and evangelical churches) and eastern (used by most of Eastern Orthodox Churches and Ancient Churches of the East).

You can also find eastern and western Pentecost plus Corpus Christi and Ash Wednesday dates with DateOfEaster.

A bit of history

Sometimes I need to find a certain Christian festive day's date. A long ago I created a Ruby gem for this: when_easter. Now I thought to create something like this in Swift.

Installation

CocoaPods

DateOfEaster is compatibile with CocoaPods. Just add this to your Podfile:

pod 'DateOfEaster'

SPM

DateOfEaster is Swift Package Manager compatible. Add following to your Package.swift:

import PackageDescription

let package = Package(
    [...]
    dependencies: [
        .Package(url: "https://github.com/Loyolny/DateOfEaster.git", majorVersion: versionNumber)
    ]
)

Framework

You can also build DateOfEaster as a framework for iOS, macOS, tvOS or watchOS. After building it, drag the created .framework file into your Xcode project.

Manual

Just drag DateOfEaster.swift file into your project

Usage

Find a western Easter date:

import DateOfEaster

let westernEaster2015 = Date.westernEasterDate(year: 2015)

Find an eastern Easter date:

import DateOfEaster

let easter1983 = Date.easternEasterDate(year: 1983)

Find Pentecost dates:

import DateOfEaster

let lastYearsEasternPentecost = Date.easternPentecostDate(year: 2016)

Find Corpus Christi date for this year:

let year = Calendar.current.dateComponents([.year], from: Date()).year

let thisYearsCorpusChristi = Date.corpusChristiDate(year: year)

Find Ash Wednesday date for this year:

let year = Calendar.current.dateComponents([.year], from: Date()).year

let thisYearsCorpusChristi = Date.ashWednesdayDate(year: year)

Caveats

Date.easternEasterDate and Date.westernEasterDate return Date optional. Both eastern and western date calcutation are subject to certain limitations:

  • Western date has to be year 1583 or later. There was no Gregorian calendar before.
  • Eastern date has to be between year 1900 and 2199 due to changing time distance between Gergorian and Julian calendars.

Otherwise both functions will return nil.

Examples

There are iOS, macOS ,tvOS and watchOS frameworks in DateOfEaster project.

# Clone the repository
$ https://github.com/Loyolny/DateOfEaster.git

# Enter the directory
$ cd DateOfEaster

# Install pod dependencies
$ pod Install

# Open the workspace file
$ open DateOfEaster.xcworkspace

Playground

A playground is included in the project for you to learn how to use this library. Just build DateOfEaster iOS target and play!

Attributions

Both Easter date calcutation algorithms were taken from Wikipedia:

Tests

DateOfEaster includes a suite of tests for all functions of the library. They are tested with Xcode for iOS, macOS and tvOS. They were also run with Swift compiler under macOS and Ubuntu 14.

License

This project is distributed under a MIT license. See the LICENSE file for details.

Author

DateOfEaster was created by Michał Nierebiński