#calendar #chinese #lunar #solar #leap #localization

不依赖 std chinese-lunisolar-calendar

传统的中国农历,又称農曆或陰曆,以月亮为基础,通常被称为农历。

29 个版本

0.2.0 2023年11月29日
0.1.26 2023年9月11日
0.1.25 2023年3月15日
0.1.23 2022年11月2日
0.1.3 2018年12月21日

#95日期和时间

Download history 67/week @ 2024-04-21 46/week @ 2024-04-28 194/week @ 2024-05-05 118/week @ 2024-05-12 86/week @ 2024-05-19 39/week @ 2024-05-26 65/week @ 2024-06-02 56/week @ 2024-06-09 111/week @ 2024-06-16 80/week @ 2024-06-23 36/week @ 2024-06-30 80/week @ 2024-07-07 21/week @ 2024-07-14 19/week @ 2024-07-21 153/week @ 2024-07-28 39/week @ 2024-08-04

每月 238 次下载
用于 omnical

MIT 许可证

140KB
2.5K SLoC

中国农历

CI

传统的中国农历,又称農曆或陰曆,以月亮为基础,通常被称为农历。

由于农历的60年周期,以及每个月的日期没有固定规则,以及农历年的月数不固定,在不参考其他日历的情况下使用农历可能具有挑战性。阴阳历是为了解决这个问题而设计的,它结合了阳历(公历)和农历,确保了准确性、可预测性和实用性。

此库允许您在阴阳历和阳历之间无缝转换日期,计算八字(八字)权重,并将日期转换为中文文本字符串。此外,它还可以将中文文本字符串解析为简体中文和繁体中文中的日期。

示例

use chinese_lunisolar_calendar::SolarDate;

let solar_date = SolarDate::from_ymd(2019, 1, 15).unwrap();

assert_eq!("二〇一九年一月十五日", solar_date.to_string());
use chinese_lunisolar_calendar::{LunisolarDate, SolarDate};

let lunisolar_date = LunisolarDate::from_solar_date(SolarDate::from_ymd(2019, 1, 15).unwrap()).unwrap();

assert_eq!("二〇一八 戊戌、狗年 臘月 初十", lunisolar_date.to_string());

assert_eq!("二〇一八 戊戌、狗年 臘月 初十", format!("{lunisolar_date}"));
assert_eq!("二〇一八 戊戌、狗年 腊月 初十", format!("{lunisolar_date:#}"));

use chinese_lunisolar_calendar::EarthlyBranch;
assert_eq!(43, lunisolar_date.get_ba_zi_weight(EarthlyBranch::Ninth));

要计算八字权重,必须启用 ba-zi-weight 功能。

无 Std

禁用默认功能以编译此crate而无需std。

[dependencies.chinese-lunisolar-calendar]
version = "*"
default-features = false

Crates.io

https://crates.io/crates/chinese-lunisolar-calendar

文档

https://docs.rs/chinese-lunisolar-calendar

许可证

MIT

依赖项

~1.4–7.5MB
~42K SLoC