Module icu_calendar::indian

source ·
Expand description

This module contains types and implementations for the Indian national calendar.

use icu::calendar::{indian::Indian, Date, DateTime};

// `Date` type
let date_iso = Date::try_new_iso_date(1970, 1, 2)
    .expect("Failed to initialize ISO Date instance.");
let date_indian = Date::new_from_iso(date_iso, Indian);

// `DateTime` type
let datetime_iso = DateTime::try_new_iso_datetime(1970, 1, 2, 13, 1, 0)
    .expect("Failed to initialize ISO DateTime instance.");
let datetime_indian = DateTime::new_from_iso(datetime_iso, Indian);

// `Date` checks
assert_eq!(date_indian.year().number, 1891);
assert_eq!(date_indian.month().ordinal, 10);
assert_eq!(date_indian.day_of_month().0, 12);

// `DateTime` type
assert_eq!(datetime_indian.date.year().number, 1891);
assert_eq!(datetime_indian.date.month().ordinal, 10);
assert_eq!(datetime_indian.date.day_of_month().0, 12);
assert_eq!(datetime_indian.time.hour.number(), 13);
assert_eq!(datetime_indian.time.minute.number(), 1);
assert_eq!(datetime_indian.time.second.number(), 0);

Structs§

Constants§

  • DAY_OFFSET 🔒
    The Saka calendar starts on the 81st day of the Gregorian year (March 22 or 21) which is an 80 day offset. This number should be subtracted from Gregorian dates
  • The Saka calendar is 78 years behind Gregorian. This number should be added to Gregorian dates