calendarize v0.1.1 Calendarize

A small utility that generates a calendar month array given a date.

Link to this section Summary

Functions

Generates a calendar month array given a date. Currently, week_start is the only option, and it can be any integer 1..7 or any string accepted by Timex.day_to_num(). If not specified, week_start defaults to :sun

Link to this section Types

Link to this type

build_options()

Specs

build_options() :: [{:week_start, Timex.Types.weekstart()}]

Link to this section Functions

Link to this function

build(date, opts \\ [])

Specs

build(DateTime.t() | Date.t(), build_options()) :: list()

Generates a calendar month array given a date. Currently, week_start is the only option, and it can be any integer 1..7 or any string accepted by Timex.day_to_num(). If not specified, week_start defaults to :sun

Examples

iex> Calendarize.build(~D[2020-05-15])
[
  [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]
]

iex> Calendarize.build(~D[2020-05-15], week_start: :mon)
[
  [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, 0]
]

iex> Calendarize.build(Timex.now, week_start: :mon)
[
  [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, 0]
]