Home Contents | # Current Values | Date/Time | Core4 Lua Commands

## SYNOPSIS

1. n = date:year()
2. n = date:month()
3. n = date:day()
4. n = date:dayOfWeek()
5. n = date:dayOfYear()
6. n = date:weekNumber()

## DESCRIPTION

This set of functions is used to query the broken down component values of a date.

## RETURN VALUE

Returns the single component of a date as a number.

The function date:dayOfWeek() returns the day of week, starting the week at monday (Monday=1 ... Sunday=7).

The function date:dayOfYear() returns the day of the year (1..365/366).

The function date:weekNumber() returns the the number of the week and the year the week belongs to. The year returned may be different from the stored year for weeks overlapping at the end of a year. The week number is calculated in accordance with ISO 8601: Weeks start on monday and the first thursday of a year is always in week 1 of that year. Sometimes a year might have 53 weeks.

## ERRORS

Raises an error if date is not a date instance.

## EXAMPLE

> >
d = clock.newDate(2000, 09, 17) print(d:year(), d:month(), d:day())
2000 9 17

## SEE ALSO

clock.currentDate, clock.newDate, date(), date:addDays, date:addMonths, date:addYears, date:days90, date:daysInMonth, date:daysInYear, date:daysTo, date:format, date:isNull, date:isValid, date:set, date:setDays90, tostring(date)