Year (ParsiDateTime) - jalalvandi/ParsiDate GitHub Wiki
year
(on ParsiDateTime)
Method Returns the year component of the Persian date associated with this ParsiDateTime
instance.
Description
This method provides read-only access to the year part of the date component stored within the ParsiDateTime
object. It does not perform any calculations or modifications.
Arguments
This method takes no arguments. It is called on an existing ParsiDateTime
instance (self
).
Returns
- An integer type (e.g.,
i32
,u16
, depending on the implementation) representing the Persian year of theParsiDateTime
instance.
Note: This method typically does not return an error, as it retrieves a value from an existing, presumably valid, object.
Examples (Rust)
use parsidate::ParsiDateTime; // Assuming ParsiDateTime and its constructor exist
// Create a ParsiDateTime instance
let dt = ParsiDateTime::new(1403, 5, 2, 15, 30, 45).expect("Failed to create ParsiDateTime");
// Get the year component
let current_year = dt.year();
// Verify the year
assert_eq!(current_year, 1403);
println!("The year is: {}", current_year); // Output: The year is: 1403
// Example with a different year
let dt_another_year = ParsiDateTime::new(1399, 12, 29, 0, 0, 0).expect("Failed to create ParsiDateTime");
assert_eq!(dt_another_year.year(), 1399);