pub struct LinearTime {
pub day_part: bool,
pub hour: Hour24,
pub minute: Minute,
pub second: Option<Second>,
}Expand description
Time expression showing time linearly - from day part down to second.
As a bare minimum, the hour and the minute must be declared:
use chinese_format::{*, gregorian::*};
assert_eq!(
LinearTime {
day_part: false,
hour: 19.try_into()?,
minute: 24.try_into()?,
second: None,
}.to_chinese(Variant::Simplified),
Chinese {
logograms: "十九点二十四分".to_string(),
omissible: false
}
);
assert_eq!(
LinearTime {
day_part: true,
hour: 19.try_into()?,
minute: 24.try_into()?,
second: None,
}.to_chinese(Variant::Simplified),
"傍晚七点二十四分"
);
assert_eq!(
LinearTime {
day_part: false,
hour: 22.try_into()?,
minute: 48.try_into()?,
second: Some(37.try_into()?),
}.to_chinese(Variant::Simplified),
"二十二点四十八分三十七秒"
);
assert_eq!(
LinearTime {
day_part: true,
hour: 8.try_into()?,
minute: 31.try_into()?,
second: Some(52.try_into()?),
}.to_chinese(Variant::Simplified),
"上午八点三十一分五十二秒"
);
assert_eq!(
LinearTime {
day_part: true,
hour: 20.try_into()?,
minute: 31.try_into()?,
second: Some(52.try_into()?),
}.to_chinese(Variant::Simplified),
"晚上八点三十一分五十二秒"
);
assert_eq!(
LinearTime {
day_part: false,
hour: 18.try_into()?,
minute: 05.try_into()?,
second: Some(07.try_into()?),
}.to_chinese(Variant::Simplified),
"十八点零五分零七秒"
);
Fields§
§day_part: boolDescribes whether the DayPart should be included: in this case,
the hour component is automatically converted to Hour12.
hour: Hour24The hour, in the format of a digital clock.
minute: MinuteThe minute.
second: Option<Second>Optionally, the second.
Trait Implementations§
Source§impl ChineseFormat for LinearTime
impl ChineseFormat for LinearTime
fn to_chinese(&self, variant: Variant) -> Chinese
Source§impl Clone for LinearTime
impl Clone for LinearTime
Source§fn clone(&self) -> LinearTime
fn clone(&self) -> LinearTime
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LinearTime
impl Debug for LinearTime
Source§impl Hash for LinearTime
impl Hash for LinearTime
Source§impl Ord for LinearTime
impl Ord for LinearTime
Source§fn cmp(&self, other: &LinearTime) -> Ordering
fn cmp(&self, other: &LinearTime) -> Ordering
1.21.0 · 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
Source§impl PartialEq for LinearTime
impl PartialEq for LinearTime
Source§impl PartialOrd for LinearTime
impl PartialOrd for LinearTime
impl Copy for LinearTime
impl Eq for LinearTime
impl StructuralPartialEq for LinearTime
Auto Trait Implementations§
impl Freeze for LinearTime
impl RefUnwindSafe for LinearTime
impl Send for LinearTime
impl Sync for LinearTime
impl Unpin for LinearTime
impl UnwindSafe for LinearTime
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