Created
November 25, 2025 00:55
-
-
Save catamorphism/ef81bbe3ba1d6594fca945627e4f3254 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use icu::calendar::cal::{ChineseTraditional}; | |
| use icu::calendar::Date; | |
| fn test_calendar(y: i32, m: u8, d: u8) { | |
| // Creating ISO date: 1987-08-15. | |
| let date_iso = Date::try_new_iso(y, m, d) | |
| .expect("Failed to initialize ISO Date instance."); | |
| let chinese = ChineseTraditional::new(); | |
| let date_chinese = date_iso.to_calendar(chinese); | |
| let year_chinese = date_chinese.year().cyclic().expect("should be cyclic"); | |
| println!("{} {} {} {}", year_chinese.year, year_chinese.related_iso, date_chinese.month().ordinal, date_chinese.month().standard_code); | |
| println!(" Gregorian: {} {} {}", y, m, date_iso.month().standard_code); | |
| } | |
| fn main() { | |
| for month in 1..13 { | |
| test_calendar(1987, month, 15); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment