Time (ParsiDateTime) - jalalvandi/ParsiDate GitHub Wiki

Method time (on ParsiDateTime)

Returns the time components (hour, minute, second) of this ParsiDateTime as a tuple.

Description

This method provides read-only access to the time portion of the ParsiDateTime instance. It extracts the hour, minute, and second values and returns them packaged together in a tuple.

The order of elements in the tuple is (hour, minute, second).

This is useful when you need to access all time components together, for example, for comparison or passing to other functions.

Assumption: This method assumes the ParsiDateTime instance holds valid time components (0-23 for hour, 0-59 for minute/second), as usually ensured by safe constructors. If the instance was created unsafely with invalid time components, this method will return those invalid values in the tuple.

Returns

  • A tuple (u8, u8, u8) or similar integer types, containing (hour, minute, second).

Examples (Rust)

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

// Create a ParsiDateTime instance
let dt = ParsiDateTime::new(1403, 5, 2, 15, 30, 45).unwrap(); // 15:30:45

// Get the time components as a tuple
let time_tuple = dt.time();

// Verify the tuple content
assert_eq!(time_tuple, (15, 30, 45));

// Alternatively, destructure the tuple
let (h, m, s) = dt.time();
assert_eq!(h, 15);
assert_eq!(m, 30);
assert_eq!(s, 45);

// Example with zero values
// let dt_midnight = ParsiDateTime::new(1404, 1, 1, 0, 0, 0).unwrap();
// assert_eq!(dt_midnight.time(), (0, 0, 0));