Month (ParsiDateTime) - jalalvandi/ParsiDate GitHub Wiki

Method month (on ParsiDateTime)

Returns the month component of the date part of this ParsiDateTime.

Description

This method provides simple, read-only access to the month-of-the-year value stored within the ParsiDateTime instance. It specifically refers to the month component of the underlying date.

The months are numbered according to the standard Persian (Hejri-Shamsi) calendar:

  • 1: Farvardin (فروردین)
  • 2: Ordibehesht (اردیبهشت)
  • 3: Khordad (خرداد)
  • 4: Tir (تیر)
  • 5: Mordad (مرداد)
  • 6: Shahrivar (شهریور)
  • 7: Mehr (مهر)
  • 8: Aban (آبان)
  • 9: Azar (آذر)
  • 10: Dey (دی)
  • 11: Bahman (بهمن)
  • 12: Esfand (اسفند)

Assumption: This method assumes the ParsiDateTime instance holds a valid month number (1-12) within its date component, as usually ensured by safe constructors.

Returns

  • An integer (u8 or similar type) representing the month, where 1 corresponds to Farvardin and 12 corresponds to Esfand.

Examples (Rust)

use parsidate::ParsiDateTime; // Assuming use of a hypothetical ParsiDateTime struct

// Example 1: Getting the month Mordad (5)
let dt = ParsiDateTime::new(1403, 5, 2, 15, 30, 45).unwrap();
assert_eq!(dt.month(), 5);

// Example 2: Getting the month Esfand (12)
// let dt_dec = ParsiDateTime::new(1403, 12, 1, 10, 0, 0).unwrap();
// assert_eq!(dt_dec.month(), 12);