From 7221cf353e8595a41e9b433eaf4f0e23bb12f1f2 Mon Sep 17 00:00:00 2001 From: GramThanos Date: Thu, 3 Aug 2017 20:15:49 +0300 Subject: [PATCH] Added isInMonth method --- source/jsCalendar.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/source/jsCalendar.js b/source/jsCalendar.js index d0f0486..b0e5f8a 100644 --- a/source/jsCalendar.js +++ b/source/jsCalendar.js @@ -866,6 +866,34 @@ var jsCalendar = (function(){ } }; + // Check if date is in active month + JsCalendar.prototype.isInMonth = function(date){ + // If no arguments or null + if (typeof date === "undefined" || date === null) { + // Return + return false; + } + + // Parse date and get month + month = this._parseDate(date); + month.setHours(0, 0, 0, 0); + month.setDate(1); + + // Parse active month date + active = this._parseDate(this._date); + active.setHours(0, 0, 0, 0); + active.setDate(1); + + // If same month + if (month.getTime() == active.getTime()) { + return true; + } + // Other month + else { + return false; + } + }; + // Set language JsCalendar.prototype.setLanguage = function(code) { // Check if language exist