Struct NaiveWeekdayTime
pub struct NaiveWeekdayTime {
weekday: Weekday,
time: NaiveTime,
}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§
§impl NaiveWeekdayTime
impl NaiveWeekdayTime
pub const fn new(weekday: Weekday, time: NaiveTime) -> Self
pub const fn new(weekday: Weekday, time: NaiveTime) -> Self
Creates a new weekday time from its components.
pub 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.
pub fn wrapping_add_signed(&self, rhs: TimeDelta) -> (Self, i64)
pub fn wrapping_add_signed(&self, rhs: TimeDelta) -> (Self, 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§
§impl Clone for NaiveWeekdayTime
impl Clone for NaiveWeekdayTime
§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 more§impl Debug for NaiveWeekdayTime
impl Debug for NaiveWeekdayTime
§impl<'de> Deserialize<'de> for NaiveWeekdayTime
Available on crate feature serde only.
impl<'de> Deserialize<'de> for NaiveWeekdayTime
serde only.§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
§impl Display for NaiveWeekdayTime
impl Display for NaiveWeekdayTime
§impl FromStr for NaiveWeekdayTime
impl FromStr for NaiveWeekdayTime
§impl Ord for NaiveWeekdayTime
impl Ord for NaiveWeekdayTime
§impl PartialEq for NaiveWeekdayTime
impl PartialEq for NaiveWeekdayTime
§impl PartialOrd for NaiveWeekdayTime
impl PartialOrd for NaiveWeekdayTime
§impl Serialize for NaiveWeekdayTime
Available on crate feature serde only.
impl Serialize for NaiveWeekdayTime
serde only.