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 在 日期和时间
每月 238 次下载
用于 omnical
140KB
2.5K SLoC
中国农历
传统的中国农历,又称農曆或陰曆,以月亮为基础,通常被称为农历。
由于农历的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
许可证
依赖项
~1.4–7.5MB
~42K SLoC