Methods
(static) getDateArr(value) → {Object|null}
Retrieves date values from an array ([ year, month, day ]).
Parameters:
Name | Type | Description |
---|---|---|
value |
Array.<Object> | An array expressing a date |
- Source:
Returns:
An object with the date values ({ year:, month:, day: }) or null in case of invalid param
- Type
- Object | null
Example
getDateArr( [ 2021, 1, 31 ] ); // returns { year: 2021, month: 1, day: 31 }
getDateArr( [] ); // returns null
- - -
(static) getDateDate(value) → {Object|null}
Retrieves date values from a Date instance.
Parameters:
Name | Type | Description |
---|---|---|
value |
Date | A Date instance |
- Source:
Returns:
An object with the date values ({ year:, month:, day: }) or null in case of invalid param
- Type
- Object | null
Example
getDateDate( new Date( 2021, 0, 31 ) ); // returns { year: 2021, month: 1, day: 31 }
getDateDate( new Date( 'bla.. bla..' ); // returns null
- - -
(static) getDateObj(value) → {Object|null}
Retrieves date values from an object ({ year:, month:, day: }).
Parameters:
Name | Type | Description |
---|---|---|
value |
Object | An object expressing a date |
- Source:
Returns:
An object with the date values ({ year:, month:, day: }) or null in case of invalid param
- Type
- Object | null
Example
getDateObj( { year: 2021, month: 1, day: 31 } ); // returns { year: 2021, month: 1, day: 31 }
getDateObj( { year: 2021, month: 1 } ); // returns null
- - -
(static) getDateRepr(value, patternopt) → {Object|null}
Retrieves date values from a string (in representation format).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
value |
string | A string expressing a date | |
pattern |
string |
<optional> |
A representation pattern |
- Source:
Returns:
An object with the date values ({ year:, month:, day: }) or null in case of invalid param
- Type
- Object | null
Example
getDateRepr( '31/01/2021' ); // returns { year: 2021, month: 1, day: 31 }
getDateRepr( '20210131' ); // returns null
- - -
(static) getDateStr(value) → {Object|null}
Retrieves date values from a string (in YYYYMMDD format).
Parameters:
Name | Type | Description |
---|---|---|
value |
string | A string expressing a date |
- Source:
Returns:
An object with the date values ({ year:, month:, day: }) or null in case of invalid param
- Type
- Object | null
Example
getDateStr( '20210131' ); // returns { year: 2021, month: 1, day: 31 }
getDateStr( '2021' ); // returns null
- - -