The code below is for a NeoBook function (written in JScript) that can be Called for this purpose ...
Code: Select all
{NeoBook Function}
Version=5.80
Language=JScript
Param=[%FullYear]|Number|FullYear e.g. 2014
Param=[%Month]|Number|Month e.g. 1 or 2 or 12
Param=[%DayOfMonth]|Number|Day of Month e.g. 1 or 2 or 31
Param=[%NamesOfDays]|Text|Names of Days e.g. Sunday,Monday,Tuesday, ... Saturday
Param=[%DOWNumber]|Variable|Calculated Number of Day of Week
Param=[%DOWName]|Variable|Calculated Name of Day of Week
{End}
//gkDayOfWeek
var MonthBase0 = [%Month] - 1;
var dateObject = new Date([%FullYear], MonthBase0, [%DayOfMonth]);
nbSetVar('[%DOWNumber]', dateObject.getDay());
//var days = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
var dayNames = "[%NamesOfDays]";
var days = dayNames.split(",");
nbSetVar('[%DOWName]', days[dateObject.getDay()]);
Then, whenever you wish to deploy it, do the following ...
Code: Select all
Call "gkDayOfWeek" "2014" "10" "29" "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday" "[thisDOWNumber]" "[thisDOWName]"
... display results
AlertBox "gkDayOfWeek" "[thisDOWNumber] ... [thisDOWName]"
a) avoids problems associated with differing date formats (by accepting year, month and date in 3 separate fields)
b) facilitates the return of names (of the days of the week) in your language of choice ... just start with whatever is Sunday in your language