pub struct Zemen { /* private fields */ }
Expand description
An Ethiopian Date.
Implementations
sourceimpl Zemen
impl Zemen
sourcepub fn year(&self) -> i32
pub fn year(&self) -> i32
Get the year.
let qen: Zemen = Zemen::from_eth_cal(2000, 1, 1).unwrap();
assert_eq!(qen.year(), 2000);
sourcepub fn month(&self) -> Month
pub fn month(&self) -> Month
Get the month.
let qen: Zemen = Zemen::from_eth_cal(2000, 1, 1).unwrap();
assert_eq!(qen.month(), Month::Meskerem);
sourcepub fn day(&self) -> u8
pub fn day(&self) -> u8
Get the day of the month.
let qen: Zemen = Zemen::from_eth_cal(2000, 1, 30).unwrap();
assert_eq!(qen.day(), 30);
sourcepub fn today() -> Self
pub fn today() -> Self
returns the current date in Ethiopian date.
let today: time::Date = time::OffsetDateTime::now_utc().date();
let zare: Zemen = Zemen::today();
assert_eq!(today, zare.to_gre());
sourcepub fn from_gre_cal(year: i32, month: u8, day: u8) -> Result<Self, ComponentRange>
pub fn from_gre_cal(year: i32, month: u8, day: u8) -> Result<Self, ComponentRange>
Takes a gregorian calendar, converts into Ethiopian calendar and
returns a Zemen
instance.
let date: Date = Date::from_calendar_date(2000, Month::January, 1).unwrap();
let qen: Zemen = Zemen::from_gre_cal(2000, 1, 1).unwrap();
assert_eq!(date, qen.to_gre());
sourcepub fn from_gre_date(gc_date: &Date) -> Self
pub fn from_gre_date(gc_date: &Date) -> Self
Builds a new Zemen
instance from a borrowed time::Date
.
let date: Date = Date::from_calendar_date(2000, Month::January, 1).unwrap();
let qen: Zemen = Zemen::from_gre_date(&date);
assert_eq!(date, qen.to_gre());
sourcepub fn from_eth_cal(year: i32, month: u8, day: u8) -> Result<Self, ComponentRange>
pub fn from_eth_cal(year: i32, month: u8, day: u8) -> Result<Self, ComponentRange>
Create an Ethiopian date from it’s number representations
let qen = Zemen::from_eth_cal(1992, 4, 22).unwrap();
assert_eq!(qen.year(), 1992);
assert_eq!(qen.month(), Month::Tahasass);
assert_eq!(qen.day(), 22);
sourcepub fn to_gre(&self) -> Date
pub fn to_gre(&self) -> Date
Convertes the current Ethiopian date into time::Date
.
let qen: Zemen = Zemen::from_eth_cal(1992, 4, 22).unwrap();
let date: Date = Date::from_calendar_date(2000, Month::January, 1).unwrap();
assert_eq!(date, qen.to_gre());
sourcepub fn from_jdn(jdn: i32) -> Result<Self, ComponentRange>
pub fn from_jdn(jdn: i32) -> Result<Self, ComponentRange>
Create an Ethiopian date from Julian day number.
assert_eq!(Zemen::from_jdn(2_451_545), Zemen::from_eth_cal(1992, 4, 22));
assert_eq!(Zemen::from_jdn(2_458_485), Zemen::from_eth_cal(2011, 4, 23));
assert_eq!(Zemen::from_jdn(2_458_849), Zemen::from_eth_cal(2012, 4, 21));
sourcepub fn to_jdn(&self) -> i32
pub fn to_jdn(&self) -> i32
Get the Julian day number for the Ethiopian date.
assert_eq!(Zemen::from_eth_cal(1992, 4, 22).unwrap().to_jdn(), 2_451_545);
assert_eq!(Zemen::from_eth_cal(2011, 4, 23).unwrap().to_jdn(), 2_458_485);
assert_eq!(Zemen::from_eth_cal(2012, 4, 21).unwrap().to_jdn(), 2_458_849);
Trait Implementations
impl StructuralPartialEq for Zemen
Auto Trait Implementations
impl RefUnwindSafe for Zemen
impl Send for Zemen
impl Sync for Zemen
impl Unpin for Zemen
impl UnwindSafe for Zemen
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more