Project Status: Active – The project has reached a stable, usable state and is being actively developed. CI Status codecov.io MIT License

GitHub | crates.io | Documentation | Issues

julian is a Rust library for converting between Julian day numbers and dates in the Gregorian calendar (either proleptic or with the Reformation occurring at a given date) and/or the proleptic Julian calendar. There are also features for querying details about years & months in a "reforming" Gregorian calendar and how they are affected by the calendar reformation date of your choice.

Installation

julian requires version 1.66 of Rust or higher. To use the julian library in your Cargo project, add the following to your Cargo.toml:

toml [dependencies] julian = "0.1.0"

Examples

Before you construct a date, you must first choose a calendar in which to reckon dates. Calendar::GREGORIAN is the proleptic Gregorian calendar, which should be both simple and useful enough for most basic purposes.

To convert a Julian day number to a date in a calendar, use the Calendar::at_jdn() method, like so:

```rust use julian::{Calendar, Month};

let cal = Calendar::GREGORIAN; let date = cal.atjdn(2460065); asserteq!(date.year(), 2023); asserteq!(date.month(), Month::April); asserteq!(date.day(), 30); ```

So JDN 2460065 is April 30, 2023, in the proleptic Gregorian calendar.

To convert a date to a Julian day number, use Calendar::at_ymd() to construct the date, and then call its julian_day_number() method:

```rust use julian::{Calendar, Month};

let cal = Calendar::GREGORIAN; let date = cal.atymd(2023, Month::April, 30).unwrap(); asserteq!(date.juliandaynumber(), 2460065); ```

See the documentation for more things you can do!