calendar-month-array
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -13,8 +13,8 @@ module.exports = function (monthDate, opts) { | ||
var first = new Date(monthDate.getYear(), monthDate.getMonth(), 1) | ||
var last = new Date(monthDate.getYear(), monthDate.getMonth() + 1, 0) | ||
var first = new Date(monthDate.getFullYear(), monthDate.getMonth(), 1) | ||
var last = new Date(monthDate.getFullYear(), monthDate.getMonth() + 1, 0) | ||
var monthFirstDayPosition = (7 + first.getDay() - weekStartDay) % 7 | ||
var calendarLastDay = last.getDate() + monthFirstDayPosition | ||
var weeks = Math.ceil((calendarLastDay + monthFirstDayPosition) / 7) | ||
var weeks = Math.ceil(calendarLastDay / 7) | ||
var lines = new Array(weeks) | ||
@@ -21,0 +21,0 @@ var headers = new Array(7) |
{ | ||
"name": "calendar-month-array", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Generates a calendar array with the days of a single month organized by week", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -7,2 +7,12 @@ var calendar = require('../') | ||
test('proper first day and last day are found', function (t) { | ||
var date = new Date('2019-01-01 00:00:00') | ||
var expectedFirstDay = new Date('2018-12-30 00:00:00') | ||
var expectedLastDay = new Date('2019-02-02 00:00:00') | ||
var cal = calendar(date) | ||
t.deepEqual(cal[0][0], expectedFirstDay, 'first cell is 30th of dec') | ||
t.deepEqual(cal[cal.length-1][6], expectedLastDay, 'last day is 2nd of feb') | ||
t.end() | ||
}) | ||
test('calendar starts on Sunday (default)', function (t) { | ||
@@ -9,0 +19,0 @@ var expectedDay = new Date('1995-01-01 00:00:00') // it's a Sunday |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11551
182