Crates.io | koyomi |
lib.rs | koyomi |
version | 0.4.0 |
source | src |
created_at | 2018-05-24 23:05:40.830732 |
updated_at | 2021-04-26 00:43:23.337002 |
description | Japanese calendar written in Rust |
homepage | |
repository | https://github.com/panther-king/koyomi |
max_upload_size | |
id | 66943 |
size | 115,044 |
This is a calendar for Japanese.
2018
2018-01
from
and until
.
2018-01
and 2018-12
Date
has year, month, day, weekday and below.
Add koyomi
as a dependency in your Cargo.toml
[dependencies]
koyomi = "0.3"
Date
can be initialized from &str
or tuple(i32, u32, u32)
.
extern crate koyomi;
use koyomi::Date;
// Only "Y-m-d" format
let date = Date::parse("2018-01-01").unwrap();
println!("{}", date); // 2018-01-01
// Same as above
let date = Date::from_ymd(2018, 1, 1).unwrap();
println!("{}", date); // 2018-01-01
Calendar
can be initialized from Date
or CalendarBuilder
.
extern crate koyomi;
use koyomi::{Calendar, Date};
// From `Date`
let from = Date::from_ymd(2018, 1, 1).unwrap();
let until = Date::from_ymd(2018, 12, 31).unwrap();
let calendar = Calendar::new(from, until).unwrap().make();
println!("{}", calendar.len()); // 365
println!("{}", calendar[0]); // 2018-01-01
// From `CalendarBuilder`
let calendar = Calendar::build()
.from("2018-01")
.until("2018-12")
.finalize()
.unwrap()
.make();
println!("{}", calendar.len()); // 365
println!("{}", calrndar[0]); // 2018-01-01