pub struct TimeTuple { /* private fields */ }
Expand description
A wrapper for a particular time of day.
Precise to second-level.
NOTE: This cannot be 24 hours or greater - see TimeTuple::new()
for more details.
The wrapping described in TimeTuple::new()
also applies when adding and subtracting times.
Implementations§
Source§impl TimeTuple
impl TimeTuple
Sourcepub fn new(h: i32, m: i32, s: i32) -> TimeTuple
pub fn new(h: i32, m: i32, s: i32) -> TimeTuple
Produces a new TimeTuple.
Times of 24 hours or greater and negative times will wrap around 24 hours to always produce a positive time.
The value is calculated from total number of seconds so a time with a minute value of 90 would add an hour to the resulting tuple and set the minutes to 30, for example.
Sourcepub fn from_seconds(total_seconds: u64) -> TimeTuple
pub fn from_seconds(total_seconds: u64) -> TimeTuple
Same as TimeTuple::new()
but takes the total number of seconds
as its argument and calculates the hours, minutes, and seconds
from that.
Sourcepub fn now() -> TimeTuple
pub fn now() -> TimeTuple
Returns a TimeTuple
of the current time as std::time::SystemTime
provides it.
pub fn get_hours(self) -> u8
pub fn get_minutes(self) -> u8
pub fn get_seconds(self) -> u8
Sourcepub fn to_hhmm_string(self) -> String
pub fn to_hhmm_string(self) -> String
Produces a string such as 08:30 for 8 hours and 30 minutes.
Ignores seconds.
Sourcepub fn to_seconds(self) -> u32
pub fn to_seconds(self) -> u32
Gets the total number of seconds in the tuple.
Sourcepub fn to_minutes(self) -> u32
pub fn to_minutes(self) -> u32
Gets the total number of minutes in the tuple, ignoring seconds.
Sourcepub fn add_seconds(&mut self, seconds: i32)
pub fn add_seconds(&mut self, seconds: i32)
Adds a number of seconds to the TimeTuple,
wrapping the same way TimeTuple::new()
does.
Sourcepub fn subtract_seconds(&mut self, seconds: i32)
pub fn subtract_seconds(&mut self, seconds: i32)
Subtracts a number of seconds from the TimeTuple,
wrapping the same way TimeTuple::new()
does.
Sourcepub fn add_minutes(&mut self, minutes: i32)
pub fn add_minutes(&mut self, minutes: i32)
Adds a number of minutes to the TimeTuple,
wrapping the same way TimeTuple::new()
does.
Sourcepub fn subtract_minutes(&mut self, minutes: i32)
pub fn subtract_minutes(&mut self, minutes: i32)
Subtracts a number of minutes from the TimeTuple,
wrapping the same way TimeTuple::new()
does.
Sourcepub fn add_hours(&mut self, hours: i32)
pub fn add_hours(&mut self, hours: i32)
Adds a number of hours to the TimeTuple,
wrapping the same way TimeTuple::new()
does.
Sourcepub fn subtract_hours(&mut self, hours: i32)
pub fn subtract_hours(&mut self, hours: i32)
Subtracts a number of hours from the TimeTuple,
wrapping the same way TimeTuple::new()
does.
Trait Implementations§
Source§impl AddAssign for TimeTuple
impl AddAssign for TimeTuple
Source§fn add_assign(&mut self, other: TimeTuple)
fn add_assign(&mut self, other: TimeTuple)
+=
operation. Read moreSource§impl Ord for TimeTuple
impl Ord for TimeTuple
Source§impl PartialOrd for TimeTuple
impl PartialOrd for TimeTuple
Source§impl SubAssign for TimeTuple
impl SubAssign for TimeTuple
Source§fn sub_assign(&mut self, other: TimeTuple)
fn sub_assign(&mut self, other: TimeTuple)
-=
operation. Read more