#calendar #chinese #command-line-tool #cli

bin+lib nongli

A Rust library and CLI tool for Chinese calendar

8 unstable releases (3 breaking)

new 0.4.1 Jan 10, 2025
0.4.0 Jan 1, 2025
0.3.1 Dec 25, 2024
0.2.1 Dec 24, 2024
0.1.1 Oct 30, 2023

#94 in Date and time

Download history 16/week @ 2024-09-25 4/week @ 2024-12-04 8/week @ 2024-12-11 160/week @ 2024-12-18 373/week @ 2024-12-25 160/week @ 2025-01-01 135/week @ 2025-01-08

828 downloads per month
Used in omnical

MIT license

82KB
2K SLoC

Nongli: A Rust library and CLI tool for Chinese calendar

github crates.io github License Preview

Note: This project is in early development and not guaranteed to run on every platform. Bug reports are welcome.

Install (as an executable)

cargo install nongli

or

cargo install --git https://github.com/supertsy5/nongli

As a library

Talk is cheap, let me show the code.

fn test() {
    use chrono::NaiveDate;
    use nongli::{ChineseDate, SolarTerm};
    let date = NaiveDate::from_ymd_opt(2023, 10, 30).unwrap();
    let chinese_date = ChineseDate::new(2023, 09, false, 16).unwrap();
    assert_eq!(ChineseDate::from_gregorian(&date), Some(chinese_date));
    assert_eq!(chinese_date.to_gregorian(), date);
    assert_eq!(
        SolarTerm::from_date(&NaiveDate::from_ymd_opt(2023, 10, 25).unwrap()),
        Some(SolarTerm::Shuangjiang)
    );
}

Development

Tip: run

. aliases.sh

for common aliases.

Clone this repository and run:

cargo build

Dependencies

~1–1.7MB
~27K SLoC