I want to create business hours for everyday of the week, rather than Monday through Friday and Saturday and Sunday. I'm using Twilio functions and Twilio Studio, however everything I've found online is not working. Currently I'm using the example they provide and I was wondering if someone can help me figured it out. Here is the code I'm using:
exports.handler = function(context, event, callback) {
// With timezone:
// In Functions/Configure, add NPM name: moment-timezone, version: 0.5.14
// Timezone function reference: https://momentjs.com/timezone/
let moment = require('moment-timezone');
//
// timezone needed for Daylight Saving Time adjustment
let timezone = event.timezone || 'America/New_York';
console.log("+ timezone: " + timezone);
//
const hour = moment().tz(timezone).format('H');
const dayOfWeek = moment().tz(timezone).format('d');
if ((hour >= 7 && hour < 19) && (dayOfWeek >= 1 && dayOfWeek <= 5)) {
// "open" from 7am to 7pm, PST.
response = "open";
} else {
response = "after";
}
theResponse = response + " : " + hour + " " + dayOfWeek;
console.log("+ Time request: " + theResponse);
callback(null, theResponse);
};
Thank you in advance!
Ok, so still the same place of code mentioned earlier, that this block of code will need to be updated to fit your needs.
if ((hour >= 7 && hour < 19) && (dayOfWeek >= 1 && dayOfWeek <= 5)) {
// "open" from 7am to 7pm, PST.
response = "open";
} else {
response = "after";
}
Needs changing to:
(As you gave 2 examples in your last comment, I show those below as the first two conditions.)
if ((hour >= 7 && hour < 15) && dayOfWeek == 1) { // Monday, 7am to 3pm
response = "open";
} else if ((hour >= 11 && hour < 20) && dayOfWeek == 2) { // Tuesday, 11am to 8pm
response = "open";
} else if ((/* Wednesday's hour range */) && dayOfWeek == 3) { // Wednesday
response = "open";
} else if ((/* Thursday's hour range */) && dayOfWeek == 4) { // Thursday
response = "open";
} else if ((/* Friday's hour range */) && dayOfWeek == 5) { // Friday
response = "open";
} else if ((/* Saturday's hour range */) && dayOfWeek == 6) { // Saturday
response = "open";
} else if ((/* Sunday's hour range */) && dayOfWeek == 0) { // Sunday
response = "open";
} else {
response = "after";
}
Then simply update the hour ranges for Wednesday to Sunday. Note that dayOfWeek for Sunday is 0, not 7, so that is not a typo.
I know somebody already answered this question, but this might be helpful to you or others in the future. This is adapted from a tutorial on Twilio and runs as one of their serverless functions.
There is a JSON object containing holidays, office hours, and partial days. The function returns an object with a handful of flags (open, holiday, etc.), the greeting (morning, afternoon, evening), and the reason if it's a holiday or partial day.
const Moment = require( 'moment-timezone' );
const MomentRange = require( 'moment-range' );
const moment = MomentRange.extendMoment( Moment );
const timezone = "America/New_York";
exports.handler = async function(context, event, callback) {
let response = new Twilio.Response();
let client = context.getTwilioClient();
response.setStatusCode( 200 );
response.appendHeader('Access-Control-Allow-Origin', '*');
response.appendHeader('Access-Control-Allow-Methods', 'OPTIONS, POST, GET');
response.appendHeader('Access-Control-Allow-Headers', 'Content-Type');
response.appendHeader('Content-Type', 'application/json');
let body = getCalendarInfo();
response.setBody(body);
callback(null, response);
};
function checkIfInRange( begin, end, timezone ) {
const currentDate = moment().tz( timezone ).format( 'MM/DD/YYYY' );
const now = moment().tz( timezone );
const beginMomentObject = moment.tz( `${currentDate} ${begin}`, 'MM/DD/YYYY HH:mm:ss', timezone );
const endMomentObject = moment.tz( `${currentDate} ${end}`, 'MM/DD/YYYY HH:mm:ss', timezone );
const range = moment.range( beginMomentObject, endMomentObject );
return now.within( range );
}
function getCalendarInfo() {
let body = {
isOpen: false,
isHoliday: false,
isPartialDay: false,
isRegularDay: false,
greeting: '',
reason: '',
date: '',
time: ''
};
//load JSON with schedule
const schedule = {
"holidays": {
"01/03/2023": {
"reason": "the New Year Holiday"
},
"01/16/2023": {
"reason": "Martin Luther King Jr Day"
}
},
"partialDays": {
// "12/26/2019": {
// "begin": "10:00:00",
// "end": "14:00:00",
// "reason": "the Day after Christmas"
// }
},
"regularHours": {
"Monday": {
"begin": "08:00:00",
"end": "18:00:00"
},
"Tuesday": {
"begin": "08:00:00",
"end": "18:00:00"
},
"Wednesday": {
"begin": "08:00:00",
"end": "18:00:00"
},
"Thursday": {
"begin": "08:00:00",
"end": "18:00:00"
},
"Friday": {
"begin": "08:00:00",
"end": "23:59:00"
},
"Saturday": {
"begin": null,
"end": null
},
"Sunday": {
"begin": null,
"end": null
}
}
}
body.date = moment().tz( timezone ).format( 'MM/DD/YYYY' );
body.time = moment().tz( timezone ).format( 'HH:mm:ss' );
if ( body.time < "12:00:00" ) {
body.greeting = "morning";
} else if ( body.time < "18:00:00" ) {
body.greeting = "afternoon";
} else {
body.greeting = "evening";
}
const currentDate = moment().tz( timezone ).format( 'MM/DD/YYYY' );
const isHoliday = currentDate in schedule.holidays;
const isPartialDay = currentDate in schedule.partialDays;
if ( isHoliday ) {
body.isHoliday = true;
if ( typeof( schedule.holidays[ currentDate ].reason ) !== 'undefined' ) {
body.reason = schedule.holidays[ currentDate ].reason;
}
} else if ( isPartialDay ) {
body.isPartialDay = true;
if ( typeof( schedule.partialDays[ currentDate ].reason ) !== 'undefined' ) {
body.reason = schedule.partialDays[ currentDate ].reason;
}
if ( checkIfInRange( schedule.partialDays[ currentDate ].begin,
schedule.partialDays[ currentDate ].end, timezone ) === true ) {
body.isOpen = true;
}
} else {
//regular hours
const dayOfWeek = moment().tz( timezone ).format( 'dddd' );
body.isRegularDay = true;
if ( checkIfInRange( schedule.regularHours[ dayOfWeek ].begin,
schedule.regularHours[ dayOfWeek ].end, timezone ) === true ) {
body.isOpen = true;
}
}
return body;
}
exports.handler = function(context, event, callback) {
let newyork_datetime_str = new Date().toLocaleString("en-US", {
timeZone: "America/New_York" });
const currentDay = new Date(newyork_datetime_str).getDay();
const currentHour = new Date(newyork_datetime_str).getHours();
const operatingHours = {
0: { start: 11, end: 16 }, // Sunday: 11am to 4pm
1: { start: 7, end: 20 }, // Monday: 7am to 8pm
2: { start: 7, end: 20 }, // Tuesday: 7am to 8pm
3: { start: 7, end: 20 }, // Wednesday: 7am to 8pm
4: { start: 7, end: 20 }, // Thursday: 7am to 8pm
5: { start: 7, end: 20 }, // Friday: 7am to 8pm
6: { start: 8, end: 16 } // Saturday: 8am to 8pm
};
if (operatingHours[currentDay] && currentHour >=
operatingHours[currentDay].start && currentHour <
operatingHours[currentDay].end) {
// Perform allowed action
callback(null, "open");
} else {
// Return an error or take some other action
callback(null, "closed"); }
};
Related
I am new to Twilio and want to include a kind of switch in my Studio Flow Chart that checks if we are in the defined business hours. If yes (success), it forwards to the number, if no (fail), it forwards to voicemail.
I tried to build a function, somewhat derived from this twilio git: https://github.com/twilio-labs/function-templates/tree/main/voicemail.
const moment = require('moment');
const DEFAULT_UTC_OFFSET = 0;
const DEFAULT_WORK_WEEK_START = 1; // Monday
const DEFAULT_WORK_WEEK_END = 5; // Friday
const DEFAULT_WORK_HOUR_START = 8; // 8:00, 8AM
const DEFAULT_WORK_HOUR_END = 18; // 18:59, 6:59PM
function getInteger(stringValue, defaultValue) {
const parsedNumber = parseInt(stringValue, 10);
if (isNaN(parsedNumber)) {
return defaultValue;
}
return parsedNumber;
}
exports.handler = function(context, event, callback) {
const timezone = getInteger(context.TIMEZONE_OFFSET, DEFAULT_UTC_OFFSET);
const workWeek = {
start: getInteger(context.WORK_WEEK_START, DEFAULT_WORK_WEEK_START),
end: getInteger(context.WORK_WEEK_END, DEFAULT_WORK_WEEK_END),
};
const workHour = {
start: getInteger(context.WORK_HOUR_START, DEFAULT_WORK_HOUR_START),
end: getInteger(context.WORK_HOUR_END, DEFAULT_WORK_HOUR_END),
};
const currentTime = moment().utcOffset(timezone);
const hour = currentTime.hour();
const day = currentTime.day();
// between monday and friday
const isWorkingDay = day <= workWeek.end && day >= workWeek.start;
// between 8am and 7pm
const isWorkingHour = hour <= workHour.end && hour >= workHour.start;
if (isWorkingDay && isWorkingHour) {
return true;
} else {
return false;
}
};
From the error I get (82002 – runtime application timed out), the callback must be different. What is the correct way for callback(err, response)?
Thanks.
Twilio developer evangelist here.
In a Twilio Function, in order to return a result you must call the callback function that is passed in as the third parameter to your handler function. You are getting a timeout here because you never call the callback so the function runs for 10 seconds then times out.
I'd try returning the data like this:
if (isWorkingDay && isWorkingHour) {
return callback(null, true);
} else {
return callback(null, false);
}
};
Note that it might not like primitive boolean values, so if that doesn't work, try a JavaScript object like:
if (isWorkingDay && isWorkingHour) {
return callback(null, { inWorkingTime: true });
} else {
return callback(null, { inWorkingTime: false });
}
};
I am using the XDSoft jQuery datetimepicker in my app (Ruby on Rails 4 (just for information, not using bootstrap datetimepicker)).
I was wondering if there is a way to disable/deactivate a specific time at a specific date, for example disable only 17:00 on 12/17/2014?
disabledDates: ['...'] disables a specific date.
I tried disabledDateTimes and disabledTimes but they don't work.
Thanks.
Here is one example of how this can be done using the XDSoft DateTimePicker you are asking about.
I have a specificDates array which you can use to add dates you want to target.
I also have an hoursToTakeAway multi dimensional array which corresponds with the specificDates array where you can specify the hours to take away.
HTML
<input class="eventStartDate newEventStart eventEditDate startTime eventEditMetaEntry" id="from_date" name="from_date" placeholder="Start date and time" readonly="readonly" type="text" />
Javascript
var specificDates = ['24/12/2014','17/12/2014'];
var hoursToTakeAway = [[14,15],[17]];
$('#from_date').datetimepicker({
format:'d.m.Y H:i',
timepicker: true,
lang: 'en',
onGenerate:function(ct,$i){
var ind = specificDates.indexOf(ct.dateFormat('d/m/Y'));
$('.xdsoft_time_variant .xdsoft_time').show();
if(ind !== -1) {
$('.xdsoft_time_variant .xdsoft_time').each(function(index){
if(hoursToTakeAway[ind].indexOf(parseInt($(this).text())) !== -1) {
$(this).hide();
}
});
}
}
});
Example
Fiddle
Basically I am taking advantage of the onGenerate event which happens after each calendar has been rendered. Then I am checking to see if the date matches the specified day and if it does, we iterate through all the time elements and hide the ones specified for the specific date.
Updated Fiddle implementing disable.
Fiddle 2
This code is working for me:
var specificDates = ['24/12/2014','17/12/2014'];
var hoursToTakeAway = [[14,15],[17]];
$('#from_date').datetimepicker({
format:'d.m.Y H:i',
timepicker: true,
lang: 'en',
onGenerate:function(ct,$i){
var ind = specificDates.indexOf(ct.dateFormat('d/m/Y'));
$('.xdsoft_time_variant .xdsoft_time').show();
if(ind !== -1) {
$('.xdsoft_time_variant .xdsoft_time').each(function(index){
if(hoursToTakeAway[ind].indexOf(parseInt($(this).text())) !== -1) {
$(this).hide();
}
});
}
}
});
If someone still need solution, i write code to disable ranges of time in jquery-ui-datepicker.
First I need to init ranges, that will be disabled at current date:
dateObj1 = new Date(2016,6,22,0);
dateObj2 = new Date(2016,6,27,10);
diap1 = [dateObj1, dateObj2];
dateObj1 = new Date(2016,6,27,13);
dateObj2 = new Date(2016,6,27,14);
diap2 = [dateObj1, dateObj2];
dateObj1 = new Date(2016,6,27,20);
dateObj2 = new Date(2016,6,29,10);
diap3 = [dateObj1, dateObj2];
dateObj1 = new Date(2016,6,27,0);
dateObj2 = new Date(2016,6,27,13);
diap4 = [dateObj1, dateObj2];
dateObj1 = new Date(2016,7,02,4);
dateObj2 = new Date(2016,7,02,4,59);
diap5 = [dateObj1, dateObj2];
diapazons = [diap1,diap2,diap3,diap4,diap5];
Then I need function, to proceed this ranges, detect intersections and create ranges, that will be displayed:
function getAvailableTimes(restricts, curr_year, curr_month, cur_day)
{
day_diaps = [[new Date(curr_year,curr_month,cur_day,0), new Date(curr_year,curr_month,cur_day,23,59,59)]];
restricts.forEach(function(item, i, arr) {
day_diaps.forEach(function(day_diap, i_d, arr_d) {
//console.log('day = '+day_diap.toString());
if (day_diap[0] >= item[1])
{
//console.log(i+' раньше');
}
else if (day_diap[1] <= item[0])
{
//console.log(i+' позже');
}
else if (day_diap[0] >= item[0] && day_diap[1] <= item[1])
{
//console.log(i+' закрыт полностью');
arr_d.splice(i_d,1);
}
else if (day_diap[0] >= item[0] && day_diap[1] >= item[1])
{
day_diap[0] = item[1];
//console.log(i+' ранее перекрытие, начало смещено на '+ day_diap.toString());
}
else if (day_diap[0] <= item[0] && day_diap[1] <= item[1])
{
day_diap[1] = item[0];
//console.log(i+' позднее перекрытие, конец смещен на '+ day_diap.toString());
}
else if (day_diap[0] <= item[0] && day_diap[1] >= item[1])
{
new_diap = [item[1],day_diap[1]];
arr_d.push(new_diap);
day_diap[1] = item[0];
//console.log(i+' restrict полностью умещается в диапазон '+ day_diap.toString());
//console.log(i+' добавлен диапазон '+ new_diap.toString());
}
});
});
return day_diaps;
}
And code in of datetimepicker:
<input type="text" id="default_datetimepicker"/>
<script>
$.datetimepicker.setLocale('ru');
var dates_to_disable = ['30-07-2016','31-07-2016','04-08-2016'];
$('#default_datetimepicker').datetimepicker({
formatTime:'H:i',
lang: "ru",
defaultTime:"10:00",
formatDate:'d-m-Y',
todayButton: "true",
minDate:'01-01--1970', // yesterday is minimum date
disabledDates:dates_to_disable,
onGenerate:function(ct,i){
var dates = jQuery(this).find('.xdsoft_date ');
$.each(dates, function(index, value){
year = jQuery(value).attr('data-year');
month = jQuery(value).attr('data-month');
date = jQuery(value).attr('data-date');
diaps = getAvailableTimes(diapazons,year,month,date);
net_nihrena = true;
diaps.forEach(function(day_diap, i_d, arr_d) {
net_nihrena = false;
});
if (net_nihrena)
{
jQuery(value).addClass('xdsoft_disabled');
//jQuery(value).addClass('xdsoft_restricted');
}
});
cur_date = ct;
diaps = getAvailableTimes(diapazons,ct.getFullYear(),ct.getMonth(),ct.getDate());
var times = jQuery(this).find('.xdsoft_time ');
$.each(times, function(index){
var hour = $(this).attr('data-hour');
var minute = $(this).attr('data-minute');
cur_date.setHours(hour,minute,0);
net_takogo_vremeni = true;
diaps.forEach(function(day_diap, i_d, arr_d) {
if ((day_diap[0] < cur_date && day_diap[1] > cur_date) || hour==0)
{
net_takogo_vremeni = false;
}
});
if (net_takogo_vremeni)
{
$(this).addClass('xdsoft_disabled');
//$(this).addClass('xdsoft_restricted');
}
});
},
onSelectDate : function(ct) {
}
});
</script>
I have been trying to search for a solution to my Jquery ui datepicker problem and I'm having no luck. Here's what I'm trying to do...
I have an application where i'm doing some complex PHP to return a JSON array of dates that I want BLOCKED out of the Jquery UI Datepicker. I am returning this array:
["2013-03-14","2013-03-15","2013-03-16"]
Is there not a simple way to simply say: block these dates from the datepicker?
I've read the UI documentation and I see nothing that helps me. Anyone have any ideas?
You can use beforeShowDay to do this
The following example disables dates 14 March 2013 thru 16 March 2013
var array = ["2013-03-14","2013-03-15","2013-03-16"]
$('input').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ array.indexOf(string) == -1 ]
}
});
Demo: Fiddle
IE 8 doesn't have indexOf function, so I used jQuery inArray instead.
$('input').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [$.inArray(string, array) == -1];
}
});
If you also want to block Sundays (or other days) as well as the array of dates, I use this code:
jQuery(function($){
var disabledDays = [
"27-4-2016", "25-12-2016", "26-12-2016",
"4-4-2017", "5-4-2017", "6-4-2017", "6-4-2016", "7-4-2017", "8-4-2017", "9-4-2017"
];
//replace these with the id's of your datepickers
$("#id-of-first-datepicker,#id-of-second-datepicker").datepicker({
beforeShowDay: function(date){
var day = date.getDay();
var string = jQuery.datepicker.formatDate('d-m-yy', date);
var isDisabled = ($.inArray(string, disabledDays) != -1);
//day != 0 disables all Sundays
return [day != 0 && !isDisabled];
}
});
});
$('input').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
return [ array.indexOf(string) == -1 ]
}
});
beforeShowDate didn't work for me, so I went ahead and developed my own solution:
$('#embeded_calendar').datepicker({
minDate: date,
localToday:datePlusOne,
changeDate: true,
changeMonth: true,
changeYear: true,
yearRange: "-120:+1",
onSelect: function(selectedDateFormatted){
var selectedDate = $("#embeded_calendar").datepicker('getDate');
deactivateDates(selectedDate);
}
});
var excludedDates = [ "10-20-2017","10-21-2016", "11-21-2016"];
deactivateDates(new Date());
function deactivateDates(selectedDate){
setTimeout(function(){
var thisMonthExcludedDates = thisMonthDates(selectedDate);
thisMonthExcludedDates = getDaysfromDate(thisMonthExcludedDates);
var excludedTDs = page.find('td[data-handler="selectDay"]').filter(function(){
return $.inArray( $(this).text(), thisMonthExcludedDates) >= 0
});
excludedTDs.unbind('click').addClass('ui-datepicker-unselectable');
}, 10);
}
function thisMonthDates(date){
return $.grep( excludedDates, function( n){
var dateParts = n.split("-");
return dateParts[0] == date.getMonth() + 1 && dateParts[2] == date.getYear() + 1900;
});
}
function getDaysfromDate(datesArray){
return $.map( datesArray, function( n){
return n.split("-")[1];
});
}
For DD-MM-YY use this code:
var array = ["03-03-2017', '03-10-2017', '03-25-2017"]
$('#datepicker').datepicker({
beforeShowDay: function(date){
var string = jQuery.datepicker.formatDate('dd-mm-yy', date);
return [ array.indexOf(string) == -1 ]
}
});
function highlightDays(date) {
for (var i = 0; i < dates.length; i++) {
if (new Date(dates[i]).toString() == date.toString()) {
return [true, 'highlight'];
}
}
return [true, ''];
}
If you want to disable particular date(s) in jquery datepicker then here is the simple demo for you.
<script type="text/javascript">
var arrDisabledDates = {};
arrDisabledDates[new Date("08/28/2017")] = new Date("08/28/2017");
arrDisabledDates[new Date("12/23/2017")] = new Date("12/23/2017");
$(".datepicker").datepicker({
dateFormat: "dd/mm/yy",
beforeShowDay: function (date) {
var day = date.getDay(),
bDisable = arrDisabledDates[date];
if (bDisable)
return [false, "", ""]
}
});
</script>
I am trying to get the events from the native calendar for a date given by user,i am not able to get the events date specific.How can i do this ?
private void getEvents() {
try {
EventList eventList = (EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_ONLY);
Enumeration events = eventList.items();
while (events.hasMoreElements()) {
Event event = (Event)events.nextElement();
if(eventList.isSupportedField(Event.LOCATION) && event.countValues(Event.LOCATION) > 0) {
String location = event.getString(Event.LOCATION, 0);
Dialog.alert(location);
}
if(eventList.isSupportedField(Event.SUMMARY) && event.countValues(Event.SUMMARY) > 0) {
String subject = event.getString(Event.SUMMARY, 0);
Dialog.alert(subject);
}
if(eventList.isSupportedField(Event.START) && event.countValues(Event.START) > 0) {
long start = event.getDate(Event.START,0);
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy HH:mm");
String dateString = sdf.formatLocal(start);
Dialog.alert(dateString);
}
if(eventList.isSupportedField(Event.END)&& event.countValues(Event.END) > 0) {
long end = event.getDate(Event.END, 0);
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy HH:mm");
String dateString = sdf.formatLocal(end);
Dialog.alert(dateString);
}
}
}
catch (PIMException e) {
Dialog.alert(e.getMessage());
}
}
how to modify this code to be displayed for the given date ?
How about:
Calendar cal = Calendar.getInstance();
cal.setTimeMillis(start);
if (cal.get(Calendar.YEAR) == requestedYear && cal.get(Calendar.MONTH) == requestedMonth && cal.get(Calendar.DAY) == requestedDay) {
// display event
}
I'm currently working on a Jquery datepicker where holidays are disabled and all sundays, except for the first one in each month. I have been trying to play around a little with the code, and found out how to disable all sundays and holidays, but i cant figure out how to enable the first sunday of evey month.
Currently my code looks like this:
<script type="text/javascript">
(function(){
var natDays = [[12, 24],[12, 25], [1,1], [12, 31]];
var daysToDisable = [0];
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1
&& date.getDate() == natDays[i][1]) {
return [false, natDays[i][2] + '_day'];
}
}
for (i = 0; i < daysToDisable.length; i++) {
if ($.inArray(day, daysToDisable) != -1) {
return [false];
}
}
return [true];
}
// Datepicker
$('#datepicker').datepicker({
inline: true,
firstDay: 1,
changeYear: true,
changeMonth: true,
beforeShowDay: nationalDays,
});
});
</script>
Logically, the first Sunday of the month is always on or before the 7th and the second (and subsequent) Sundays are after the 7th.
function nationalDays(date) {
for (i = 0; i < natDays.length; i++) {
if (date.getMonth() == natDays[i][0] - 1 && date.getDate() == natDays[i][1]) {
return [false, natDays[i][2] + '_day'];
}
}
if (date.getDate() > 7 && $.inArray(date.getDay(), daysToDisable) != -1)
return [false];
}
return [true];
}
I would also suggest to change the structure of your natDays array to a flat array in order to speed up lookups. For your class prefixes (which are not set in your example), you can use an extra array with matching indices. Your final function would look like this:
var natDays = ["12-24", "12-25", "1-1", "12-31"];
var classPrefixes = ["", "", "", ""];
var daysToDisable = [0];
function nationalDays(date) {
var index = $.inArray((date.getMonth() + 1) + "-" + date.getDate(), natDays);
if (index != -1) {
return [false, classPrefixes[index] + '_day'];
}
if (date.getDate() > 7 && $.inArray(date.getDay(), daysToDisable) != -1)
return [false];
}
return [true];
}
The method you're looking for is date.getDay(), which will return a number from 0 to 6, with 0 being Sunday.
function nationalDays(date) {
if(date.getDay() == 0) {
// do stuff...