Skip to content

vdoroshko/MonthCalendar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 

Repository files navigation

MonthCalendar

The MonthCalendar object provides support for generating month calendars.

Usage Example

Fetch arrays of weeks containing Date objects for the current month of the year:

var currentDate = new Date;
var monthCalendar = new MonthCalendar(currentDate.getFullYear(), currentDate.getMonth(), 1);

var weekRow;
while (weekRow = monthCalendar.fetchRow()) {
    console.log(weekRow);
}

Will output:

[Log] [
    Mon Jan 01 2018 00:00:00 GMT+0300 (+03),
    Tue Jan 02 2018 00:00:00 GMT+0300 (+03),
    Wed Jan 03 2018 00:00:00 GMT+0300 (+03),
    Thu Jan 04 2018 00:00:00 GMT+0300 (+03),
    Fri Jan 05 2018 00:00:00 GMT+0300 (+03),
    Sat Jan 06 2018 00:00:00 GMT+0300 (+03),
    Sun Jan 07 2018 00:00:00 GMT+0300 (+03)
] (7)

[Log] [
    Mon Jan 08 2018 00:00:00 GMT+0300 (+03),
    Tue Jan 09 2018 00:00:00 GMT+0300 (+03),
    Wed Jan 10 2018 00:00:00 GMT+0300 (+03),
    Thu Jan 11 2018 00:00:00 GMT+0300 (+03),
    Fri Jan 12 2018 00:00:00 GMT+0300 (+03),
    Sat Jan 13 2018 00:00:00 GMT+0300 (+03),
    Sun Jan 14 2018 00:00:00 GMT+0300 (+03)
] (7)

[Log] [
    Mon Jan 15 2018 00:00:00 GMT+0300 (+03),
    Tue Jan 16 2018 00:00:00 GMT+0300 (+03),
    Wed Jan 17 2018 00:00:00 GMT+0300 (+03),
    Thu Jan 18 2018 00:00:00 GMT+0300 (+03),
    Fri Jan 19 2018 00:00:00 GMT+0300 (+03),
    Sat Jan 20 2018 00:00:00 GMT+0300 (+03),
    Sun Jan 21 2018 00:00:00 GMT+0300 (+03)
] (7)

Syntax

new MonthCalendar();
new MonthCalendar(date);
new MonthCalendar(year, month[, firstDayOfWeek]);

Parameters

date

A Date object.

year

Integer value representing the year. Values from 0 to 99 map to the years 1900 to 1999.

month

Integer value representing the month, beginning with 0 for January to 11 for December.

firstDayOfWeek

Optional. Integer value representing the first day of the week, beginning with 0 for Sunday to 6 for Saturday.

Return Value

A new MonthCalendar object.

Exceptions

TypeError

Thrown if the year or month or firstDayOfWeek parameters are not a number type.

RangeError

Thrown if the year and month parameters results in an invalid combination.

Thrown if the firstDayOfWeek parameter is out of range of valid values (0–6).

Methods

Browser Support

  • Chrome
  • Opera 5+
  • Firefox
  • Safari
  • Internet Explorer 5.5+

License

Licensed under the BSD 3-Clause License.

About

Provides support for generating month calendars

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published