Skip to main content

CalendarMetadata

Trait CalendarMetadata 

Source
pub trait CalendarMetadata {
    // Required methods
    fn epoch() -> JDN;
    fn description() -> &'static str;
    fn cultural_origin() -> &'static str;

    // Provided method
    fn cycle_length() -> Option<CycleYear> { ... }
}
Expand description

Trait for calendar metadata and information

This trait provides access to calendar-specific metadata such as epoch information, cycle information, and cultural context. Implementers should provide accurate historical and cultural information about their calendar systems.

§Implementation Requirements

Calendar implementations must:

  • Provide accurate epoch dates with historical sources
  • Document cycle lengths with cultural references
  • Include cultural origin information
  • Optionally provide reference sources for verification

§Reference Sources Contract

Implementers of this trait should document their reference sources for:

  • Epoch dates and historical accuracy
  • Cycle calculations and astronomical basis
  • Cultural practices and calendar rules
  • Regional variations and historical changes

Recommended reference sources include:

  • Historical astronomical records
  • Cultural and religious texts
  • Academic research on calendar systems
  • Government or institutional standards

§Example

use calendar_core::{CalendarMetadata, JDN};

struct MyCalendar;

impl CalendarMetadata for MyCalendar {
    fn epoch() -> JDN {
        // Epoch based on historical records
        1948439 // Example: March 22, 2024 CE
    }

    fn cycle_length() -> Option<u32> {
        Some(60) // 60-year cycle common in Indonesian calendars
    }

    fn description() -> &'static str {
        "Traditional Indonesian calendar with 60-year cycle"
    }

    fn cultural_origin() -> &'static str {
        "Javanese court calendar system, integrated with Islamic calendar"
    }
}

Required Methods§

Source

fn epoch() -> JDN

Get the epoch (starting date) for this calendar

The epoch represents the starting point of the calendar system, typically corresponding to a historically significant date.

§Returns

Julian Day Number of the calendar’s epoch

§Historical Context

Implementers should base epoch dates on reliable historical sources and document any uncertainties or variations in historical records.

Source

fn description() -> &'static str

Get a description of this calendar system

Provides a concise description of the calendar system, including its main characteristics and usage context.

§Returns

String slice describing the calendar system

Source

fn cultural_origin() -> &'static str

Get the cultural/ethnic origin of this calendar

Identifies the cultural, ethnic, or religious group that developed and primarily uses this calendar system.

§Returns

String slice identifying the cultural origin

§Examples
  • “Javanese court calendar”
  • “Balinese Pawukon system”
  • “Islamic Hijri calendar”
  • “Chinese lunisolar calendar”

Provided Methods§

Source

fn cycle_length() -> Option<CycleYear>

Get the cycle length if this calendar uses cycles

Many Indonesian calendars use cyclical systems (e.g., 60-year cycles). This method returns the length of such cycles if applicable.

§Returns
  • Some(length) - Number of years in the cycle
  • None - Calendar doesn’t use year cycles
§Examples
  • Javanese calendar: 60-year cycle
  • Chinese calendar: 60-year cycle
  • Gregorian calendar: No cycle (returns None)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§