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.
Since the crate is still under heavy development, and me being a beginner rust
programmer, it won't be published on crates.io
yet. For now you can clone the
repo and link to it in your Cargo.toml
like so.
```toml ...snip...
[dependencies] zemen = { path = "path/to/zemen/repo" }
...snip... ```
You can find the documantation at here.
```rust use zemen;
fn main() { // Returns the current Ethiopian date. let zare: zemen::Zemen = zemen::Zemen::today();
// print: ጥር 14/2015
println!("Zare: {}", zare);
// To access the individal elements
let year: i32 = zare.year(); // 2015
// Returns the zemen::Month::Tir
enum which could be casted as u8
// to get the month representain in number
// let month_num: u8 = zemen::Month::Tir as u8;
let month: zemen::Month = zare.month(); // Month::Tir
let day: u8 = zare.day(); // 14
// printing the month will print the equvalent month in amharic
println!("{}", month); // prints: ጥር
}
```
```rust use time; use zemen;
fn main() { let qen = zemen::Zemen::fromethcal(1992, 4, 22).unwrap() let day = time::Date::fromcalendardate(2000, time::Month::January, 1).unwrap();
// to convert Ethiopian to Greogroian let convertedday: time::Date = qen.togre();
// To convert Gregorian to Ethiopian let convertedqen: zemen::Zemen = zemen::Zemen::fromgre_date(&day); } ```