DayOfWeek
The DayOfWeek function computes the day of the week corresponding to a year, month, and day. The value is returned as a number 0 through 6 with Sunday being day 0.
sDOW = DayOfWeek( nYear, nMonth, nDay )
where
nYear, nMonth, nDay are the components of the date (e.g., 2007, 4, and 23).
nDOW is the day of the week with values 0 through 6, beginning with Sunday = 0.
The following script computes the day of the week and lists it in a nice format:
-- First, create a table contining the day names |
|
|
|
|
|
-- enter the year, month, and day to be evaluated |
|
|
|
|
|
-- calculate the day of the week |
|
|
-- returns Sunday as 0 |
|
|
-- For printing the result, remember that Lua tables start at |
|
-- index 1, but DayOfWeek() returns Sunday as 0, so we compensate |
|
-- by fetching the day name from the table using index [nDay+1] |
|
|
|