Crates.io | zemen |
lib.rs | zemen |
version | 0.1.7 |
source | src |
created_at | 2023-01-22 20:36:37.332896 |
updated_at | 2024-10-29 17:27:48.503829 |
description | Ethiopian to Gregorian conversion utility |
homepage | |
repository | https://github.com/omer-biz/zemen/ |
max_upload_size | |
id | 765372 |
size | 49,161 |
[!WARNING] I've recently discovered a bug that may impact its accuracy The
Zemen::today
function doesn't properly return the current date when thetime
feature is disabled. At this time, I'm unable to resolve the issue immediately. I encourage users to submit a pull request if they’re interested in contributing a fix. In the meantime, you may want to explore alternative crates that provide similar functionality or use the crate with thetime
feature turned on.Thank you for your understanding and support! I’ll update this message as soon as a resolution is available.
A date conversion crate to convert between ethiopian and gregorian dates. We
have a custom struct
to represent ethiopian date, i.e. Zemen
, and we are
using an external crate time
, and specifically time::Date
, to represent
gregorian dates.
The crate uses the Beyene-Kudlek algorithm to convert between jdn (Julian Day number) and ethiopic calender. And the time crate to convert between jdn (Julian Day number) and gregorian date.
Docs found here
cargo add zemen
use time::{Date, Month};
use zemen::{Zemen, Werh};
use zemen::error;
fn main() -> Result<(), error::Error> {
// creating dates
// Werh means month in Ge'ez
let qen = Zemen::from_eth_cal(1992, Werh::Tahasass, 22)?;
let date = Date::from_calendar_date(2000, Month::January, 1)?;
// conversion
let converted_day = Date::from(&qen);
let converted_qen = Zemen::from(&date);
println!("date: {}", converted_day);
println!("qen: {}", converted_qen);
// accessing individual element
println!("year: {}", qen.year());
println!("month: {}", qen.month());
println!("month(number): {}", qen.month() as u8);
println!("day: {}", qen.day());
// get the next, and previous date. `next` and `previous` consume `self`
let nege = qen.next();
println!("nege: {}", nege);
let tilant = nege.previous().previous();
println!("tilant: {}", tilant);
// get the next month
let qetay_wer = tilant.month().next();
println!("wer: {}", qetay_wer);
// get the previous month
let yalef_wer = tilant.month().previous();
println!("wer: {}", yalef_wer);
Ok(())
}
use zemen::*;
fn main() -> Result<(), error::Error> {
let qen = Zemen::from_eth_cal(2015, Werh::Tir, 10)?;
let formatted = qen.format("ዛሬ DD, MMM D-YYYY ነው");
// prints: ዛሬ ረቡዕ, ጥር 10-2015 ነው
println!("{}", formatted);
Ok(())
}