Helper to format and parse dates in different ways
npm install dates-formatter-helperKind: global class
- DatesFormatter
- new DatesFormatter()
- _instance_
- [.format(date, [asUTC])](#DatesFormatter+format) ⇒ string
- [.formatRange(dateRange, [asUTC])](#DatesFormatter+formatRange) ⇒ Array.<string>
- [.parse(dateString, [asUTC])](#DatesFormatter+parse) ⇒ Date
- [.parseRange(dateStringRange, [asUTC])](#DatesFormatter+parseRange) ⇒ Array.<Date> \| Array.<object>
- _static_
- .DatesFormatter
- [new DatesFormatter(mode, [options])](#new_DatesFormatter.DatesFormatter_new)
DatesFormatter Class
Formats Date object as string
Kind: instance method of DatesFormatter
Returns: string - String representation of Date
| Param | Type | Default | Description |
| ------- | -------------------- | ----------------- | -------------------------------- |
| date | Date | | Date object to convert |
| [asUTC] | boolean | true | Whether to use date input as UTC |
Formats date range as strings
Kind: instance method of DatesFormatter
Returns: Array.<string> - String representation of Dates
| Param | Type | Default | Description |
| --------- | ------------------------------- | ----------------- | -------------------------------- |
| dateRange | Array.<Date> | | Date range to convert |
| [asUTC] | boolean | true | Whether to use date input as UTC |
Parses date string to Date
Kind: instance method of DatesFormatter
Returns: Date - The parsed date
| Param | Type | Default | Description |
| ---------- | -------------------- | ----------------- | -------------------------------- |
| dateString | string | | Date string to parse |
| [asUTC] | boolean | true | Whether to use date input as UTC |
Parses date string arrays to Date
Kind: instance method of DatesFormatter
Returns: Array.<Date> \| Array.<object> - The parsed dates
| Param | Type | Default | Description |
| --------------- | --------------------------------- | ----------------- | -------------------------------- |
| dateStringRange | Array.<string> | | Date strings array to parse |
| [asUTC] | boolean | true | Whether to use date input as UTC |
Kind: static class of DatesFormatter
#### new DatesFormatter(mode, [options])
Creates an instance of DatesFormatter.
| Param | Type | Default | Description |
| --------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------- | -------------------------------------------- |
| mode | 'year' \| 'month' \| 'week' \| 'date' | | Mode to use for formatting |
| [options] | FormatterOptions | {} | Config to override default formatter strings |
Kind: global enum
Properties
| Name | Default |
| ----- | ------------------ |
| YEAR | year |
| MONTH | month |
| WEEK | week |
| DATE | date |
Kind: global typedef
Properties
| Name | Type |
| ------------- | ------------------- |
| [dateFormat] | string |
| [weekFormat] | string |
| [monthFormat] | string |
| [yearFormat] | string |