Skip to main content

Crate year_helper

Crate year_helper 

Source
Expand description

§Year Helper

This library provides some useful functions to deal with years.

The year parameter follows the ISO 8601 proleptic Gregorian calendar, using astronomical year numbering like Chrono’s NaiveDate. This means year 0 is 1 BCE, year -1 is 2 BCE, and so on.

§Usage

let year = 2020;
let month = 2;

let leap_year = year_helper::is_leap_year(year);

let days_in_month = year_helper::get_days_in_month(year, month);
let days_in_year = year_helper::get_days_in_year(year);

// or use the following functions if the year has been determined whether it is a leap year
let days_in_month = year_helper::get_days_in_month_with_leap_year(leap_year, month);
let days_in_year = year_helper::get_days_in_year_with_leap_year(leap_year);

Functions§

get_days_in_month
Calculate how many days in a month.
get_days_in_month_2Deprecated
Calculate how many days in a month.
get_days_in_month_with_leap_year
Calculate how many days in a month.
get_days_in_year
Calculate how many days in a year.
get_days_in_year_2Deprecated
Calculate how many days in a year.
get_days_in_year_with_leap_year
Calculate how many days in a year.
is_leap_year
Determine whether a year is a leap year or not.