4 个版本 (2 个稳定版)
1.1.0 | 2023年3月25日 |
---|---|
1.0.0 | 2017年1月6日 |
0.1.1 | 2016年3月31日 |
0.1.0 | 2016年3月30日 |
#202 在 日期和时间
700 每月下载量
用于 9 个 Crates (6 直接使用)
8KB
138 行
Computus
Computus 在 Rust 中计算复活节
用法
将以下内容添加到您的 Cargo.toml 中
[dependencies]
computus = "1.1.0"
您可以使用以下方式找到特定年份的复活节星期日
// 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
:
概述
使用计算历法方法计算公历/儒略历复活节星期日的日期。
功能
可选功能
chrono
: 启用直接生成chrono::NaiveDate
示例
您可以使用以下方式找到特定年份的复活节
// 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));
}
依赖
~0–280KB