Month
A class which encapsulates a calendar view of a month, and offers information about the weeks and days within that calendar view.
// December 2018 using Monday as week start
const m = new Month({
date : '2018-12-01',
weekStartDay : 1
});
m.eachWeek((week, dates) => console.log(dates.map(d => d.getDate())))
Useful configs and functions
| Config / Function | Description |
|---|---|
| date | Date the month encapsulates |
| weekStartDay | First day of the week (0=Sun, 6=Sat) |
| eachWeek | Iterate over each week with its dates |
| eachDay | Iterate over each day in the month |
See also
- DateHelper - Date manipulation and formatting utility
- DatePicker - Date picker widget using Month
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Configure as
trueto have the visibleDayColumnIndex and visibleColumnCount properties respect the configured nonWorkingDays. -
nonWorkingDays : Object<String, Boolean>
Non-working days as an object where keys are day indices, 0-6 (Sunday-Saturday), and the value is
true. Defaults to nonWorkingDays. -
Configure as
trueto always have the month encapsulate six weeks. This is useful for UIs which must be a fixed height.Has a corresponding runtime sixWeeks property.
-
The week start day, 0 meaning Sunday, 6 meaning Saturday. Defaults to weekStartDay.
Properties
Properties are getters/setters or publicly accessible variables on this class-
The number of days in the calendar for this month. This will always be a multiple of 7, because this represents the number of calendar cells occupied by this month.
-
The date of the last cell in the calendar view of this month.
-
The first date of the current month.
-
The last date of the current month.
-
Configure as
trueto always have the month encapsulate six weeks. This is useful for UIs which must be a fixed height.Has a corresponding sixWeeks config.
-
The date of the first cell in the calendar view of this month.
-
The number of weeks in the calendar for this month.
-
The number of visible days in the week as defined by the
nonWorkingDaysandhideNonWorkingDaysoptions.