Date (ParsiDateTime) - parsicore/parsidate GitHub Wiki

Method date (on ParsiDateTime)

Returns the ParsiDate component (year, month, day) of this ParsiDateTime.

Description

This method provides read-only access to the date portion of the ParsiDateTime instance. It extracts and returns a ParsiDate object representing the specific year, month, and day associated with the timestamp, effectively discarding the time information (hour, minute, second).

This is useful when you only need to perform date-specific operations or comparisons on a ParsiDateTime value.

Returns

  • A ParsiDate instance containing the year, month, and day of this ParsiDateTime.

Examples (Rust)

use parsidate::{ParsiDateTime, ParsiDate}; // Assuming these types exist

// Create a ParsiDateTime instance
let dt = ParsiDateTime::new(1403, 8, 15, 10, 30, 0).unwrap(); // Aban 15th, 1403, at 10:30:00

// Extract the date component
let date_part: ParsiDate = dt.date();

// Verify that the extracted date matches the expected ParsiDate
assert_eq!(date_part, ParsiDate::new(1403, 8, 15).unwrap());

// You can then use methods specific to ParsiDate on the result
// assert_eq!(date_part.year(), 1403);
// assert_eq!(date_part.month(), 8);
// assert_eq!(date_part.day(), 15);
// let weekday = date_part.weekday(); // Example: get weekday of the date part