Contents

sbooth/juliandaynumber

Julian day number and Julian date calculations supporting the following calendars:

Installation

Swift Package Manager

Add a package dependency to https://github.com/sbooth/JulianDayNumber in Xcode.

Manual or Custom Build

  1. Clone the JulianDayNumber repository.
  2. swift build.

Examples

  1. Calculate the Julian date for the total solar eclipse on 1919-05-29.
let jd = AstronomicalCalendar.julianDateFrom(year: 1919, month: 5, day: 29)
// 2422107.5

[!NOTE] The astronomical calendar is a hybrid calendar using the Julian calendar for dates on or before October 4, 1582 and the Gregorian calendar for dates on or after October 15, 1582.

  1. Convert the Julian date 2422107.5 to a Date instance.
let d = Date(julianDate: 2422107.5)
// Foundation.Date	1919-05-29 00:00:00 UTC
  1. Convert the Gregorian calendar date 2013-10-31 to a date in the Julian calendar.
let julianYMD = GregorianCalendar.convert(year: 2013, month: 10, day:31, to: JulianCalendar.self)
// (year: 2013, month: 10, day: 18)

Documentation

The latest documentation is hosted by Swift Package Index.

All public classes, structs, and functions should be documented. If you notice a documentation shortcoming please open a new issue.

Limits

The following table summarizes the arithmetic limits for Julian day number calculations on platforms where Int is 64 bits.

| Calendar | Minimum JDN | Maximum JDN | | --- | --- | --- | | Armenian | Int.min + 341 | Int.max | | Baháʼí | Int.min | Int.max | | Coptic | Int.min | Int.max | | Egyptian | Int.min + 611 | Int.max | | Ethiopian | Int.min | Int.max | | French Republican | Int.min | Int.max | | Gregorian | Int.min | Int.max | | Hebrew | Int.min + 106960181 | 355839970905664 | | Islamic | Int.min | Int.max | | Julian | Int.min | Int.max | | Khwarizmian | Int.min + 341 | Int.max | | Macedonian | Int.min | Int.max | | Maya Long Count | Int.min | Int.max | | Persian | Int.min + 336 | Int.max | | Śaka | Int.min | Int.max | | Syrian | Int.min | Int.max |

License

JulianDayNumber is released under the MIT License.

Package Metadata

Repository: sbooth/juliandaynumber

Default branch: main

README: README.md