pub struct Clock<Time>where
Time: TimeLike,{ /* private fields */ }Expand description
Renders a clock in emoji
§Examples
#[cfg(feature = "time")]
{
use time::Time;
use emoji_clock_2::{Clock, Rounding};
let clock = Clock::new(Time::from_hms(12, 29, 00).unwrap()).with_rounding(Rounding::Floor);
assert_eq!("🕛", clock.to_string());
}#[cfg(feature = "chrono")]
{
use chrono::NaiveTime;
use emoji_clock_2::{Clock, Meridiem};
let am_clock = Clock::new(NaiveTime::from_hms_opt(9, 15, 00).unwrap()).with_meridiem(Meridiem::default());
assert_eq!("🕤🌞", am_clock.to_string());
let pm_clock = Clock::new(NaiveTime::from_hms_opt(21, 44, 00).unwrap()).with_meridiem(Meridiem{ am: '🌞', pm: '🌙' });
assert_eq!("🕤🌙", pm_clock.to_string());
}Implementations§
Source§impl<Time> Clock<Time>where
Time: TimeLike,
impl<Time> Clock<Time>where
Time: TimeLike,
Sourcepub const fn new(time: Time) -> Self
pub const fn new(time: Time) -> Self
Creates a new clock with round strategy and no meridiem indicators
Sourcepub fn with_rounding(self, rounding: Rounding) -> Self
pub fn with_rounding(self, rounding: Rounding) -> Self
Sets rounding strategy (Round by default)
Sourcepub fn with_meridiem(self, meridiem: Meridiem) -> Self
pub fn with_meridiem(self, meridiem: Meridiem) -> Self
Enables meridiem (AM/PM) indicators (disabled by default)
Trait Implementations§
impl<Time> Copy for Clock<Time>
Auto Trait Implementations§
impl<Time> Freeze for Clock<Time>where
Time: Freeze,
impl<Time> RefUnwindSafe for Clock<Time>where
Time: RefUnwindSafe,
impl<Time> Send for Clock<Time>where
Time: Send,
impl<Time> Sync for Clock<Time>where
Time: Sync,
impl<Time> Unpin for Clock<Time>where
Time: Unpin,
impl<Time> UnwindSafe for Clock<Time>where
Time: UnwindSafe,
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