Function calendarize::calendarize[][src]

pub fn calendarize(date: NaiveDate) -> Vec<[u32; 7]>

Generate a calendar view of the given date’s month.

Each vector element is an array of seven numbers representing weeks (starting on Sundays), and each value is the numeric date. A value of zero means a date that not exists in the current month.

Examples

use chrono::*;
use calendarize::calendarize;

let date = NaiveDate::parse_from_str("2021-01-02", "%Y-%m-%d").unwrap();
// Week = [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
println!("{:?}", calendarize(date));
// [0, 0, 0, 0, 0, 1, 2],
// [3, 4, 5, 6, 7, 8, 9],
// [10, 11, 12, 13, 14, 15, 16],
// [17, 18, 19, 20, 21, 22, 23],
// [24, 25, 26, 27, 28, 29, 30],
// [31, 0, 0, 0, 0, 0, 0]