pub struct TimeOfDay {
pub hour: i32,
pub minute: i32,
}Expand description
A value representing a time during the day, independent of the date that day might fall on or the time zone.
The time is represented by hour and minute pair. Once
created, both values cannot be changed.
You can create TimeOfDay using the constructor which requires both hour and
minute or using DateTime object.
Hours are specified between 0 and 23, as in a 24-hour clock.
let release_time = TimeOfDay::new(15, 0); // 3:00pm
let booking = DateTime::new_with_time(&app, 2018, 10, 20, 16, 30, 4, 0, 0);
let room_booked = TimeOfDay::from_date_time(&app, &booking); // 4:30pmSee also:
showTimePicker, which returns this type.MaterialLocalizations, which provides methods for formatting values of this type according to the chosenLocale.DateTime, which represents date and time, and is subject to eras and time zones.
Fields§
§hour: i32The selected hour, in 24 hour time from 0..23.
minute: i32The selected minute.
Implementations§
Source§impl TimeOfDay
impl TimeOfDay
Sourcepub const HOURS_PER_DAY: i32 = 24
pub const HOURS_PER_DAY: i32 = 24
The number of hours in one day, i.e. 24.
Sourcepub const HOURS_PER_PERIOD: i32 = 12
pub const HOURS_PER_PERIOD: i32 = 12
The number of hours in one day period (see also DayPeriod), i.e. 12.
Sourcepub const MINUTES_PER_HOUR: i32 = 60
pub const MINUTES_PER_HOUR: i32 = 60
The number of minutes in one hour, i.e. 60.
Sourcepub const fn new(hour: i32, minute: i32) -> TimeOfDay
pub const fn new(hour: i32, minute: i32) -> TimeOfDay
Creates a time of day.
The hour argument must be between 0 and 23, inclusive. The minute
argument must be between 0 and 59, inclusive.
Sourcepub fn now(app: &App) -> TimeOfDay
pub fn now(app: &App) -> TimeOfDay
Creates a time of day based on the current time, in the local time zone.
Sourcepub fn from_date_time(app: &App, time: &DateTime) -> TimeOfDay
pub fn from_date_time(app: &App, time: &DateTime) -> TimeOfDay
Sourcepub fn replacing(&self, hour: Option<i32>, minute: Option<i32>) -> TimeOfDay
pub fn replacing(&self, hour: Option<i32>, minute: Option<i32>) -> TimeOfDay
Returns a new TimeOfDay with the hour and/or minute replaced.
Sourcepub fn hour_of_period(&self) -> i32
pub fn hour_of_period(&self) -> i32
Which hour of the current period (e.g., am or pm) this time is.
For 12AM (midnight) and 12PM (noon) this returns 12.
Sourcepub fn period_offset(&self) -> i32
pub fn period_offset(&self) -> i32
The hour at which the current period starts.
Sourcepub fn format(&self, app: &mut App, context: BuildContext) -> String
pub fn format(&self, app: &mut App, context: BuildContext) -> String
Returns the localized string representation of this time of day.
This is a shortcut for MaterialLocalizations::format_time_of_day.
Sourcepub fn is_before(&self, other: &TimeOfDay) -> bool
pub fn is_before(&self, other: &TimeOfDay) -> bool
Whether this TimeOfDay occurs earlier than other.
Does not account for day or sub-minute differences. This means that “00:00” of the next day is still before “23:00” of this day.
Sourcepub fn is_after(&self, other: &TimeOfDay) -> bool
pub fn is_after(&self, other: &TimeOfDay) -> bool
Whether this TimeOfDay occurs later than other.
Does not account for day or sub-minute differences. This means that “00:00” of the next day is still before “23:00” of this day.
Sourcepub fn is_at_same_time_as(&self, other: &TimeOfDay) -> bool
pub fn is_at_same_time_as(&self, other: &TimeOfDay) -> bool
Whether this TimeOfDay occurs at the same time as other.
Does not account for day or sub-minute differences. This means that “00:00” of the next day is still before “23:00” of this day.
Sourcepub fn compare_to(&self, other: &TimeOfDay) -> Ordering
pub fn compare_to(&self, other: &TimeOfDay) -> Ordering
Compares this TimeOfDay object to other independent of date.
Does not account for day or sub-minute differences. This means that “00:00” of the next day is still before “23:00” of this day.
A compare_to function returns:
Ordering::Lessif this TimeOfDayis_beforeother.Ordering::Equalif this DateTimeis_at_same_time_asother, andOrdering::Greaterotherwise (when this TimeOfDayis_afterother).
Trait Implementations§
impl Copy for TimeOfDay
impl Eq for TimeOfDay
Source§impl Ord for TimeOfDay
Dart’s implements Comparable<TimeOfDay>: the order of TimeOfDay::compare_to.
impl Ord for TimeOfDay
Dart’s implements Comparable<TimeOfDay>: the order of TimeOfDay::compare_to.
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for TimeOfDay
impl PartialOrd for TimeOfDay
impl StructuralPartialEq for TimeOfDay
Auto Trait Implementations§
impl Forget for TimeOfDay
impl Freeze for TimeOfDay
impl Move for TimeOfDay
impl RefUnwindSafe for TimeOfDay
impl Send for TimeOfDay
impl Sync for TimeOfDay
impl Unpin for TimeOfDay
impl UnsafeUnpin for TimeOfDay
impl UnwindSafe for TimeOfDay
Blanket Implementations§
Source§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.