pub struct Time { /* private fields */ }Expand description
A wall clock time with second precision.
Implementations§
Source§impl Time
impl Time
pub fn new(hour: u8, minute: u8, second: u8) -> Option<Time>
pub fn hour(&self) -> u8
pub fn minute(&self) -> u8
pub fn second(&self) -> u8
Sourcepub fn twelve_hour(locale: &str) -> bool
pub fn twelve_hour(locale: &str) -> bool
Whether a locale shows times on a 12 hour clock with AM and PM (en-US).
Sourcepub fn parse_input(
s: &str,
locale: &str,
now: Time,
words: &DateWords,
) -> Option<Time>
pub fn parse_input( s: &str, locale: &str, now: Time, words: &DateWords, ) -> Option<Time>
Reads what a person types into a time field. Besides Time::parse_local: 14 (on the
hour), 1430 and 930 (digits only), 14.30, 2pm, and now or its translation (şimdi).
use zeyn::{DateWords, Time};
let now = Time::new(10, 7, 0).unwrap();
let en = DateWords::english();
assert_eq!(Time::parse_input("930", "tr", now, &en), Time::new(9, 30, 0));
assert_eq!(Time::parse_input("2pm", "en-US", now, &en), Time::new(14, 0, 0));
assert_eq!(Time::parse_input("now", "en", now, &en), Some(now));Trait Implementations§
impl Copy for Time
Source§impl<'de> Deserialize<'de> for Time
impl<'de> Deserialize<'de> for Time
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Time
Source§impl Ord for Time
impl Ord for Time
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Time
impl PartialOrd for Time
impl StructuralPartialEq for Time
impl SupportsMinMaxTotal 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 UnsafeUnpin 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