End Of Season (ParsiDateTime) - jalalvandi/ParsiDate GitHub Wiki

Method day (on ParsiDateTime)

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

Description

This method provides simple, read-only access to the day-of-the-month value stored within the ParsiDateTime instance.

The value returned will be an integer, typically between 1 and 31. The maximum valid value for the day depends on the specific month and whether the year component is a leap year:

  • Months 1-6 (Farvardin to Shahrivar) allow days 1-31.
  • Months 7-11 (Mehr to Bahman) allow days 1-30.
  • Month 12 (Esfand) allows days 1-30 in a leap year and 1-29 in a common year.

Assumption: This method assumes the ParsiDateTime instance holds a valid day number for its specific month and year, as usually ensured by safe constructors.

Returns

  • An integer (u8 or similar type) representing the day of the month (1-31).

Examples (Rust)

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

// Example 1: Getting the day '2' from a date
let dt = ParsiDateTime::new(1403, 5, 2, 15, 30, 45).unwrap(); // Mordad 2nd
assert_eq!(dt.day(), 2);

// Example 2: Getting the day '30' from the end of a leap year
let dt_leap_end = ParsiDateTime::new(1403, 12, 30, 23, 59, 59).unwrap(); // Esfand 30th, 1403 (leap year)
assert_eq!(dt_leap_end.day(), 30);

// Example 3: Getting the day '29' from the end of a common year
// let dt_common_end = ParsiDateTime::new(1404, 12, 29, 0, 0, 0).unwrap(); // Esfand 29th, 1404 (common year)
// assert_eq!(dt_common_end.day(), 29);