Date objects without time
npm install @patient-otter/dateonly```
npm install @patient-otter/dateonly
- The default date is 1970-01-01 not the current day. e.g. new DateOnly().toString() // 1970-01-01 1-12
- The Constructor only takes numbers, you must use static methods to create from
a number, string, or Date object
- The month properties are indexed at 1, so the range is where 1 is January
12 is December
`js
import DateOnly from "@patient-otter/dateonly";
const dt = new DateOnly() //1970-01-01
dt.setDate(dt.getDate() + 12)
//1970-01-13
dt.toJSON() //1970-01-13T:00:00.000Z
const dateWithTime = new Date();
const dateWithouttime = DateOnly.fromDate(dateWithTime);
const dateFromString = DateOnly.fromString('06/25/2030');
console.log(dateFromString.toString()) //'2030-06-25'
``
A date object with without time
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [year] | number | 1970 | The year the of the date |
| [date] | number | 1 | The year the of the date |
| [month] | number | 1 | The year the of the date |
Kind: global class
* DateOnly
* _instance_
* .getFullYear()
* .getMonth()
* .getDate()
* .setFullYear(v)
* .getDay()
* .setMonth(v)
* .setDate(v)
* [.toString([sep])](#DateOnly+toString)
* .toISOString()
* .toJSON()
* .toDateString()
* .isValid()
* _static_
* .fromNumber(n)
* .fromString(s)
* .fromDate(d)
* .now()
Kind: instance method of DateOnly
Returns{number}:
Kind: instance method of DateOnly
Returns{number}:
Kind: instance method of DateOnly
Returns{number}:
Kind: instance method of DateOnly
| Param | Type | Description |
| --- | --- | --- |
| v | number | The new desired value for the year |
Kind: instance method of DateOnly
Kind: instance method of DateOnly
| Param | Type | Description |
| --- | --- | --- |
| v | number | The new desired value for the value |
Kind: instance method of DateOnly
| Param | Type | Description |
| --- | --- | --- |
| v | number | The new desired value for the date |
Kind: instance method of DateOnly
Returns{string}: the date represented as a string
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [sep] | string | "-" | The seperator to use between date components |
Kind: instance method of DateOnly
Returns{string}: the date represented as an ISO8601 string
Kind: instance method of DateOnly
Returns{string}: the date represented as an ISO8601 string
Kind: instance method of DateOnly
Kind: instance method of DateOnly
Kind: static method of DateOnly
| Param | Type | Description |
| --- | --- | --- |
| n | number | The number to be converted to a DateOnly Object |
Kind: static method of DateOnly
| Param | Type | Description |
| --- | --- | --- |
| s | string | The string to read the date info from |
Kind: static method of DateOnly
| Param | Type | Description |
| --- | --- | --- |
| d | Date | The date to use in creating a new DateOnly object using the date's UTC values |
Kind: static method of DateOnly
Returns{dateonly}: A donly only object with the current local date