pub struct Time {
pub hour: IsoHour,
pub minute: IsoMinute,
pub second: IsoSecond,
pub nanosecond: NanoSecond,
}
Expand description
A representation of a time in hours, minutes, seconds, and nanoseconds
Fields§
§hour: IsoHour
0-based hour.
minute: IsoMinute
0-based minute.
second: IsoSecond
0-based second.
nanosecond: NanoSecond
Fractional second
Implementations§
source§impl Time
impl Time
sourcepub fn try_from_str(ixdtf_str: &str) -> Result<Time, ParseError>
pub fn try_from_str(ixdtf_str: &str) -> Result<Time, ParseError>
Creates a Time
from an IXDTF syntax string of a time.
Does not support parsing an IXDTF string with a date and time; for that, use DateTime
.
✨ Enabled with the ixdtf
Cargo feature.
§Examples
use icu::calendar::Time;
let time = Time::try_from_str("16:01:17.045").unwrap();
assert_eq!(time.hour.number(), 16);
assert_eq!(time.minute.number(), 1);
assert_eq!(time.second.number(), 17);
assert_eq!(time.nanosecond.number(), 45000000);
sourcepub fn try_from_utf8(ixdtf_str: &[u8]) -> Result<Time, ParseError>
pub fn try_from_utf8(ixdtf_str: &[u8]) -> Result<Time, ParseError>
Creates a Time
in the ISO-8601 calendar from an IXDTF syntax string.
✨ Enabled with the ixdtf
Cargo feature.
See Self::try_from_str()
.
Trait Implementations§
source§impl ConvertCalendar for Time
impl ConvertCalendar for Time
source§fn to_calendar<'a>(
&self,
_: &'a AnyCalendar,
) -> <Time as ConvertCalendar>::Converted<'a>
fn to_calendar<'a>( &self, _: &'a AnyCalendar, ) -> <Time as ConvertCalendar>::Converted<'a>
Converts
self
to the specified AnyCalendar
.source§impl GetField<NanoSecond> for Time
impl GetField<NanoSecond> for Time
source§fn get_field(&self) -> NanoSecond
fn get_field(&self) -> NanoSecond
Returns the value of this trait’s field
T
.source§impl InSameCalendar for Time
impl InSameCalendar for Time
source§fn check_any_calendar_kind(
&self,
_: AnyCalendarKind,
) -> Result<(), MismatchedCalendarError>
fn check_any_calendar_kind( &self, _: AnyCalendarKind, ) -> Result<(), MismatchedCalendarError>
Checks whether this type is compatible with the given calendar. Read more
source§impl Ord for Time
impl Ord for Time
source§impl PartialOrd for Time
impl PartialOrd for Time
impl Copy for Time
impl Eq for Time
impl<C> InFixedCalendar<C> for Time
impl StructuralPartialEq for Time
impl UnstableSealed for Time
Auto Trait Implementations§
impl Freeze for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> GetField<T> for Twhere
T: Copy + UnstableSealed,
impl<T> GetField<T> for Twhere
T: Copy + UnstableSealed,
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more