Function calendarize::calendarize_with_offset[][src]

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

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

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.

Offset means the number of days from sunday. For example, 1 means monday, 6 means saturday.

Examples

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

let date = NaiveDate::parse_from_str("2021-01-02", "%Y-%m-%d").unwrap();
// Week = [Mon, Tue, Wed, Thu, Fri, Sat, Sun]
println!("{:?}", calendarize_with_offset(date, 1));
// [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, 0],