Struct NaiveWeekdayTime
pub struct NaiveWeekdayTime {
weekday: Weekday,
time: NaiveTime,
}time only.Expand description
Weekday and time combination without timezone information.
This doesn’t represent an absolute point in time, but rather a recurring time on a specific weekday, e.g., “Mondays at 14:30”.
There’s no ISO 8601 equivalent for this type.
§Format
The string representation is in the format <weekday>-<time>, where
<weekday> is one of Mon, Tue, Wed, Thu, Fri, Sat, or Sun.
When parsing, the weekday is case-insensitive and supports both three-letter
and full names.
§Ordering
The ordering is first by weekday (Monday < Tuesday < … < Sunday), then by time within the day.
Fields§
§weekday: Weekday§time: NaiveTimeImplementations§
Source§impl NaiveWeekdayTime
impl NaiveWeekdayTime
Sourcepub const fn new(weekday: Weekday, time: NaiveTime) -> NaiveWeekdayTime
pub const fn new(weekday: Weekday, time: NaiveTime) -> NaiveWeekdayTime
Creates a new weekday time from its components.
Sourcepub const fn in_week(&self, week: &IsoWeek) -> Option<NaiveDateTime>
pub const fn in_week(&self, week: &IsoWeek) -> Option<NaiveDateTime>
Returns the absolute date-time in a given week.
Returns None if the resulting date-time is unrepresentable.
Sourcepub fn wrapping_add_signed(&self, rhs: TimeDelta) -> (NaiveWeekdayTime, i64)
pub fn wrapping_add_signed(&self, rhs: TimeDelta) -> (NaiveWeekdayTime, i64)
Adds a TimeDelta to the time, wrapping around the week.
Returns the new NaiveWeekdayTime and the number of weeks wrapped
around.
§Examples
use hb_time::{NaiveWeekdayTime, TimeDelta, Weekday};
let nwt = NaiveWeekdayTime::new(
Weekday::Fri,
hb_time::NaiveTime::from_hms_opt(23, 0, 0).unwrap(),
);
let (new_nwt, weeks) = nwt.wrapping_add_signed(TimeDelta::hours(2));
assert_eq!(
new_nwt,
NaiveWeekdayTime::new(
Weekday::Sat,
hb_time::NaiveTime::from_hms_opt(1, 0, 0).unwrap()
)
);
assert_eq!(weeks, 0);Trait Implementations§
Source§impl Clone for NaiveWeekdayTime
impl Clone for NaiveWeekdayTime
Source§fn clone(&self) -> NaiveWeekdayTime
fn clone(&self) -> NaiveWeekdayTime
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for NaiveWeekdayTime
impl Debug for NaiveWeekdayTime
Source§impl<'de> Deserialize<'de> for NaiveWeekdayTime
impl<'de> Deserialize<'de> for NaiveWeekdayTime
Source§fn deserialize<D>(
deserializer: D,
) -> Result<NaiveWeekdayTime, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<NaiveWeekdayTime, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for NaiveWeekdayTime
impl Display for NaiveWeekdayTime
Source§impl FromStr for NaiveWeekdayTime
impl FromStr for NaiveWeekdayTime
Source§type Err = ParseError
type Err = ParseError
Source§fn from_str(
s: &str,
) -> Result<NaiveWeekdayTime, <NaiveWeekdayTime as FromStr>::Err>
fn from_str( s: &str, ) -> Result<NaiveWeekdayTime, <NaiveWeekdayTime as FromStr>::Err>
s to return a value of this type. Read more