Class: WeekClock

chronos.WeekClock(weekRule)

Get and set week figures using a specified reckoning sytems for weeks.

Constructor

new WeekClock(weekRule)

Parameters:
Name Type Description
weekRule weekRule the description of the week.
Source:
See:
  • module:chronos for the definition of the weekRule structure.

Methods

getNumberFromWeek(weekYear, weekNumberopt, dayOfWeekopt, checkopt) → {number}

Compute day index from week figures in the defined week structure.
Parameters:
Name Type Attributes Default Description
weekYear number the year (full year, a relative integer) of the week figures. There may be 1 year difference with the year of the calendar's date.
weekNumber number <optional>
the number of the week; if not specified, this.weekBase.
dayOfWeek number <optional>
the number day of the week, following the weekRule parameter set; if not specified: this.dayBase.
check boolean <optional>
false whether a consitency check is done.
Source:
Returns:
day index, in day units (not in milliseconds or other), of the day that corresponds to the week figures.
Type
number

getWeekFigures(dayIndex, year) → {Array}

Compute week figures in the defined week structure.
Parameters:
Name Type Description
dayIndex number date stamp, in day unit, of the day whose figures are computed.
year number the algebraic year the dayIndex date belongs to.
Source:
Returns:
[0] : week number; [1] : week day number, depending on dayBase. Modulo this.weekLength value is always : 0 (or this.weekLength) for Sunday of first day, 1 for Monday etc. [2] : year offset: -1 if week belongs to last week year, 0 if in same year, 1 if in next year. [3] : weeks in year: number of weeks for the week year the date belongs to. This is not always the number of the last week (check this.weekBase)!
Type
Array