Namespace: count

count

Functions to count date related values.
Source:

Methods

(static) countDaysOfMonth(month, year) → {number|null}

Gets the number of days of a month.
Parameters:
Name Type Description
month number A month (from 1 to 12)
year number A year (to consider 29 days for february on leap years)
Source:
Returns:
A number of days or null in case of invalid params
Type
number | null
Example
countDaysOfMonth( 1, 2021 ); // returns 31
countDaysOfMonth( 2, 2021 ); // returns 28
countDaysOfMonth( 2 ); // returns null

- - -

(static) countDaysOfRange(from, till) → {number|null}

Gets the number of days of a date range including the starting and ending limits.
Parameters:
Name Type Description
from Object | Array.<Object> | string | Date A starting date of a range
till Object | Array.<Object> | string | Date A ending date of a range
Source:
Returns:
A number of days or null in case of invalid params
Type
number | null
Example
countDaysOfRange( '20210429', '20210502' ) // returns 4
countDaysOfRange( '20210502', '20210429' ) // returns -4

- - -

(static) countDaysOfYear(year) → {number|null}

Gets the number of days of a year.
Parameters:
Name Type Description
year number A year
Source:
Returns:
A number of days or null in case of invalid param
Type
number | null
Example
countDaysOfYear( 2021 ); // returns 365
countDaysOfYear( 2024 ); // returns 366
countDaysOfYear(); // returns null

- - -