4 releases (2 stable)

1.1.0 Mar 25, 2023
1.0.0 Jan 6, 2017
0.1.1 Mar 31, 2016
0.1.0 Mar 30, 2016

#167 in Date and time

Download history 340/week @ 2023-12-04 364/week @ 2023-12-11 173/week @ 2023-12-18 200/week @ 2023-12-25 251/week @ 2024-01-01 115/week @ 2024-01-08 162/week @ 2024-01-15 256/week @ 2024-01-22 162/week @ 2024-01-29 194/week @ 2024-02-05 170/week @ 2024-02-12 156/week @ 2024-02-19 212/week @ 2024-02-26 201/week @ 2024-03-04 109/week @ 2024-03-11 155/week @ 2024-03-18

680 downloads per month
Used in 9 crates (6 directly)

MIT license

8KB
138 lines

Computus

crates.io Documentation

Computus Easter calculation in Rust

Usage

Add this to your Cargo.toml:

[dependencies]
computus = "1.1.0"

You can find when Easter Sunday is for a particular year with:

// For Gregorian calendars
let easter = computus::gregorian(2016).unwrap();
assert_eq!((easter.month, easter.day), (3, 27));
// For Julian calendars
let easter = computus::julian(2016).unwrap();
assert_eq!((easter.month, easter.day), (4, 18));
// With `chrono` feature
#[cfg(feature = "chrono")] {
    use chrono::Datelike;
    let easter = computus::gregorian_naive(2023).unwrap();
    assert_eq!((easter.month(), easter.day()), (4, 9));
}

lib.rs:

Overview

Calculate the date of Easter Sunday in Gregorian/Julian calendar using the computus method.

Features

Optional features:

  • chrono: Enable directly producing a chrono::NaiveDate

Example

You can find when Easter is for a particular year with:

// For Gregorian calendars
let easter = computus::gregorian(2016).unwrap();
assert_eq!((easter.month, easter.day), (3, 27));
// For Julian calendars
let easter = computus::julian(2016).unwrap();
assert_eq!((easter.month, easter.day), (4, 18));
// With `chrono` feature
#[cfg(feature = "chrono")] {
    use chrono::Datelike;
    let easter = computus::gregorian_naive(2023).unwrap();
    assert_eq!((easter.month(), easter.day()), (4, 9));
}

Dependencies

~0–285KB