# Feature idea - Date.add

**URL:** <https://es.discourse.group/t/feature-idea-date-add/898>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [August 1, 2021, 12:34pm UTC](https://es.discourse.group/t/feature-idea-date-add/898 "2021-08-01T12:34:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![debadeep](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@debadeep](https://es.discourse.group/u/debadeep)\
**Post date:** [August 1, 2021, 12:34pm UTC](https://es.discourse.group/t/feature-idea-date-add/898/1 "2021-08-01T12:34:14Z")

</div>

I was thinking if we could simplify the process of date arithmetic by adding an "add" method, which would add a certain value to the given date object and return the new date. I propose the following structure:

`Date.prototype.add = function(unit:String, value:Number)`

Where `unit` is a specified string to denote hours, minutes, seconds, days, months etc. and `value` is the actual value being added. If `value` is negative, it would end up subtracting that from the specified date.

The reason I am proposing this is that although adding days to a date object is fairly simple, there does not appear to be any straightforward way to add minutes, seconds, and such to a certain date/time. There have been javascript libraries like moment, but it sure would be nice to have this in the ES specs.

Thoughts?

---

<div class="post-metadata">

**Author:** ![debadeep](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@debadeep](https://es.discourse.group/u/debadeep)\
**Post date:** [August 1, 2021, 12:36pm UTC](https://es.discourse.group/t/feature-idea-date-add/898/2 "2021-08-01T12:36:10Z")

</div>

Forgot to mention, looking for champions.

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [August 1, 2021, 1:12pm UTC](https://es.discourse.group/t/feature-idea-date-add/898/3 "2021-08-01T13:12:41Z")

</div>

Temporal will provide functionality similar to this

> **[GitHub - tc39/proposal-temporal: Provides standard objects and functions for...](https://github.com/tc39/proposal-temporal)**
>
> Provides standard objects and functions for working with dates and times. - GitHub - tc39/proposal-temporal: Provides standard objects and functions for working with dates and times.

---

<div class="post-metadata">

**Author:** ![debadeep](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@debadeep](https://es.discourse.group/u/debadeep)\
**Post date:** [August 1, 2021, 1:41pm UTC](https://es.discourse.group/t/feature-idea-date-add/898/4 "2021-08-01T13:41:03Z")

</div>

@aclaymore Thank you. Another date-related convenience I would love to have would be to have a destructuring capability for a Date-like object. That is to say, something like -

`const {date, month, year} = new CustomDate(<params>)`

Would it be possible to do it with a `Temporal.PlainDate` object?

---

<div class="post-metadata">

**Author:** ![aclaymore](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/aclaymore/32/501_2.png) [@aclaymore](https://es.discourse.group/u/aclaymore)\
**Post date:** [August 1, 2021, 3:01pm UTC](https://es.discourse.group/t/feature-idea-date-add/898/5 "2021-08-01T15:01:50Z")

</div>

Yes you can do:

```javascript
const {day, month, year} = plainDate;

```
