Skip to content

Instantly share code, notes, and snippets.

@catamorphism
Created November 25, 2025 00:55
Show Gist options
  • Select an option

  • Save catamorphism/ef81bbe3ba1d6594fca945627e4f3254 to your computer and use it in GitHub Desktop.

Select an option

Save catamorphism/ef81bbe3ba1d6594fca945627e4f3254 to your computer and use it in GitHub Desktop.
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