WeekdayName: Difference between revisions
Jump to navigation
Jump to search
m Ghenne moved page Weekdayname to WeekdayName |
No edit summary |
||
Line 5: | Line 5: | ||
WeekdayName returns a string representing the day of week. The required argument, ''number'', is an integer ranging from 1 to 7 that represents the number of the day of the week. The optional argument, ''abbreviate'', is a boolean expression, if ''abbreviate'' is TRUE the value returned is the three-letter abbreviation of the weekday name, otherwise the full name is returned by default. The optional parameter ''firstdayofweek'' is Sunday, if not specified. | WeekdayName returns a string representing the day of week. The required argument, ''number'', is an integer ranging from 1 to 7 that represents the number of the day of the week. The optional argument, ''abbreviate'', is a boolean expression, if ''abbreviate'' is TRUE the value returned is the three-letter abbreviation of the weekday name, otherwise the full name is returned by default. The optional parameter ''firstdayofweek'' is Sunday, if not specified. | ||
== Example == | == Example (Basic) == | ||
<pre> | <pre> | ||
Rem WeekdayName Example | Rem WeekdayName Example | ||
'WeekdayName returns string name of day | 'WeekdayName returns string name of day | ||
Dim Day1, Day2 | Dim Day1, Day2 | ||
Day1 = 1 | Day1 = 1 | ||
Line 15: | Line 16: | ||
Day2 = 2 | Day2 = 2 | ||
Print WeekdayName(Day2, TRUE, vbMonday) | Print WeekdayName(Day2, TRUE, vbMonday) | ||
</pre> | |||
== Example (JavaScript) == | |||
<pre> | |||
// WeekdayName Example | |||
/* WeekdayName returns string name of day */ | |||
WeekdayName = function (dayIndex, short, start) { | |||
var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; | |||
if (start > 0) { | |||
dayIndex += (start-1); | |||
dayIndex = dayIndex%7; | |||
} | |||
if (short) { | |||
rtnValue = days[--dayIndex].substring(0,3); | |||
} else { | |||
rtnValue = days[--dayIndex]; | |||
} | |||
return rtnValue; | |||
} | |||
var vbSunday=1,vbMonday=2,vbTuesday=3,vbWednesday=4,vbThursday=5,vbFriday=6, vbSaturday=7; | |||
var Day1=1, Day2=2; | |||
Day1 = 1; | |||
document.write(WeekdayName(Day1) + "<br>"); | |||
Day2 = 2; | |||
document.write(WeekdayName(Day2, true, vbMonday) + "<br>"); | |||
</pre> | </pre> | ||
Revision as of 07:52, 12 May 2013
WeekdayName number[, abbreviate[, firstdayofweek]])
Description
WeekdayName returns a string representing the day of week. The required argument, number, is an integer ranging from 1 to 7 that represents the number of the day of the week. The optional argument, abbreviate, is a boolean expression, if abbreviate is TRUE the value returned is the three-letter abbreviation of the weekday name, otherwise the full name is returned by default. The optional parameter firstdayofweek is Sunday, if not specified.
Example (Basic)
Rem WeekdayName Example 'WeekdayName returns string name of day Dim Day1, Day2 Day1 = 1 Print WeekdayName(Day1) Day2 = 2 Print WeekdayName(Day2, TRUE, vbMonday)
Example (JavaScript)
// WeekdayName Example /* WeekdayName returns string name of day */ WeekdayName = function (dayIndex, short, start) { var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; if (start > 0) { dayIndex += (start-1); dayIndex = dayIndex%7; } if (short) { rtnValue = days[--dayIndex].substring(0,3); } else { rtnValue = days[--dayIndex]; } return rtnValue; } var vbSunday=1,vbMonday=2,vbTuesday=3,vbWednesday=4,vbThursday=5,vbFriday=6, vbSaturday=7; var Day1=1, Day2=2; Day1 = 1; document.write(WeekdayName(Day1) + "<br>"); Day2 = 2; document.write(WeekdayName(Day2, true, vbMonday) + "<br>");
Output
Sunday Tue