4 releases (breaking)

0.4.0 Apr 26, 2021
0.3.0 Jan 5, 2020
0.2.0 Dec 7, 2019
0.1.0 May 24, 2018

#183 in Date and time

Download history 9/week @ 2024-06-11 13/week @ 2024-06-18 11/week @ 2024-06-25 27/week @ 2024-07-02 12/week @ 2024-07-16 6/week @ 2024-07-23 44/week @ 2024-07-30 17/week @ 2024-08-06 10/week @ 2024-08-13 37/week @ 2024-08-20 9/week @ 2024-08-27 99/week @ 2024-09-03 1/week @ 2024-09-17 14/week @ 2024-09-24

115 downloads per month
Used in 2 crates

Custom license

57KB
1K SLoC

koyomi

Build Status Crates.io Crates.io license

This is a calendar for Japanese.

About

  • Generate a calendar
    • Specified a year or year-and-month.
      • e.g. 2018
      • e.g. 2018-01
    • Specified between from and until.
      • e.g. 2018-01 and 2018-12
  • Generate a date
    • Date has year, month, day, weekday and below.
      • Japanese Calendar
      • Japanese weekday
      • Japanese holiday

Usage

Add koyomi as a dependency in your Cargo.toml

[dependencies]
koyomi = "0.3"

Quick Example

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

Dependencies

~1MB
~18K SLoC