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 week number; if not specified, this.weekBase i.e. the first week of any year.
dayOfWeek number <optional>
the weekday number; if not specified, this.startOfWeek i.e. the first day of the week for this culture.
check boolean <optional>
false check consistency of result; no check by default.
Source:
Returns:
day index 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