Constructor
new Cbcce(calendarRule)
Parameters:
Name | Type | Description |
---|---|---|
calendarRule |
calendarRule | The object that describes the rules of the calendar to be implemented. |
- Source:
- See:
-
- module:chronos for the definition of the calendarRule structure.
Methods
getNumber(askedObject) → {number}
Compute the timestamp from the element of a date in a given calendar.
Parameters:
Name | Type | Description |
---|---|---|
askedObject |
Object | the numeric elements of the date, collected in an object containing the elements that calendarRule prescribes. |
- Source:
Returns:
the timestamp.
- Type
- number
getObject(askedNumber) → {Object}
Build a compound object from a timestamp holding the elements as required by a given cycle hierarchy model.
Parameters:
Name | Type | Description |
---|---|---|
askedNumber |
number | a timestamp representing the date to convert. |
- Source:
Returns:
the calendar elements in the structure that calendarRule prescribes.
- Type
- Object
(static) divmod(a, d) → {Array.<number>}
Division with modulo for calendrical computations
Parameters:
Name | Type | Description |
---|---|---|
a |
number | dividend; integer recommended. |
d |
number | divisor; integer recommended. |
- Source:
Returns:
[quotient, modulo] with 0 <= modulo < d or d < modulo <= 0.
- Type
- Array.<number>
(static) isGregorianLeapYear(a) → {boolean}
Whether a year is a leap year in the Gregorian calendar, with the year origin Anno Domini as defined by Dionysius Exiguus in the 6th century.
Parameters:
Name | Type | Description |
---|---|---|
a |
number | signed integer number representing the year. 0 means 1 B.C. Leap years, are either not divisible by 100 but by 4, or divisible by 400. |
- Source:
Returns:
true if year is a leap year i.e. there is a 29 February in this year.
- Type
- boolean
(static) isJulianLeapYear(a) → {boolean}
Whether a year is a leap year in the Julian calendar, with the year origin Anno Domini as defined by Dionysius Exiguus in the 6th century.
Parameters:
Name | Type | Description |
---|---|---|
a |
number | signed integer number representing the year. 0 means 1 B.C. and so on. Leap years, either positive or negative, are divisible by 4. |
- Source:
Returns:
true if year is a leap year i.e. there is a 29 February in this year.
- Type
- boolean
(static) mod(a, d) → {number}
The Modulo function for calendrical computations.
Parameters:
Name | Type | Description |
---|---|---|
a |
number | dividend, may be positive, null or negative. |
d |
number | divisor, shall be non-zero. |
- Source:
Returns:
modulo of a divided by d, with 0 <= modulo < d or d < modulo <= 0; e.g. -2 mod 3 is +1, not -2.
- Type
- number
(static) shiftCycle(cycle, phase, period, shift, cycleBase) → {Array.<number>}
Cycle start shifting, keeping phase measure. Example : (20, 1) shifted by 2 in a 12-cycle with base 1 yields (19, 13), but (20, 6) yields (20, 6)
This operation is used for calendrical computations on Julian-Gregorian calendars (shift year start to March), but also for computations on weeks.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
cycle |
number | the rank of cycle, which is increased by 1 each time 'phase' reaches (mod (cycleBase, period)). | |
phase |
number | indicates the phase within the cycle, e.g. for the month or the day of week. (phase == cycleBase) means the start of a new cycle. | |
period |
number | the cycle's period, typically 12 or 7 for calendrical computations, but may also be the moon's month mean duration in milliseconds. | |
shift |
number | the number of units for shifting. After shifting, cycleBase is cycleBase + shift. | |
cycleBase |
number | 0 | which phase is that of a new cycle, in the parameter [cycle, phase] representation. 0 by default (like month representation with Date objects). |
- Source:
Returns:
[returnCycle, returnPhase] with: (returnCycle * period + returnPhase == cycle * period + phase) && (shift + cycleBase) <= returnPhase < (shift + cycleBase)+period.
- Type
- Array.<number>