From e2deb15925dd447c31546e5c142aa8f28a83ddcf Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Wed, 9 Jan 2019 17:41:42 +0000
Subject: [PATCH] Travis build: 936
---
README.md | 15 ++++++---------
docs/date.html | 10 +++-------
test/_30s.js | 7 ++-----
3 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/README.md b/README.md
index d3d13e68e..e1f57ad8d 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
# 30 seconds of code
[](https://github.com/30-seconds/30-seconds-of-code/blob/master/LICENSE) [](https://www.npmjs.com/package/30-seconds-of-code) [](https://www.npmjs.com/package/30-seconds-of-code) [](https://snyk.io/test/github/30-seconds/30-seconds-of-code?targetFile=package.json)
-[](https://travis-ci.com/30-seconds/30-seconds-of-code) [](https://www.codacy.com/app/Chalarangelo/30-seconds-of-code?utm_source=github.com&utm_medium=referral&utm_content=30-seconds/30-seconds-of-code&utm_campaign=Badge_Grade) [](https://codeclimate.com/github/30-seconds/30-seconds-of-code/maintainability) [](https://github.com/Flet/semistandard)
+[](https://travis-ci.com/30-seconds/30-seconds-of-code) [](https://www.codacy.com/app/Chalarangelo/30-seconds-of-code?utm_source=github.com&utm_medium=referral&utm_content=30-seconds/30-seconds-of-code&utm_campaign=Badge_Grade) [](https://github.com/Flet/semistandard)
[](https://awesome.re) [](https://www.producthunt.com/posts/30-seconds-of-code) [](https://gitter.im/30-seconds-of-code/Lobby) [](http://makeapullrequest.com)
> Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.
@@ -4491,16 +4491,14 @@ minDate(array); // 2016-01-08T22:00:00.000Z
Results in a string representation of tomorrow's date.
-Use `new Date()` to get today's date, adding one day using `Date.getDate()` and `Date.setDate()`, and converting the Date object to a string.
+Use `new Date()` to get the current date, increment by one using `Date.getDate()` and set the value to the result using `Date.setDate()`.
+Use `Date.prototype.toISOString()` to return a string in `yyyy-mm-dd` format.
```js
-const tomorrow = (long = false) => {
+const tomorrow = () => {
let t = new Date();
t.setDate(t.getDate() + 1);
- const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String(
- t.getDate()
- ).padStart(2, '0')}`;
- return !long ? ret : `${ret}T00:00:00`;
+ return t.toISOString().split('T')[0];
};
```
@@ -4508,8 +4506,7 @@ const tomorrow = (long = false) => {
Results in a string representation of tomorrow's date.
Use new Date() to get today's date, adding one day using Date.getDate() and Date.setDate(), and converting the Date object to a string.
const tomorrow = (long = false) => { +
Results in a string representation of tomorrow's date.
Use new Date() to get the current date, increment by one using Date.getDate() and set the value to the result using Date.setDate(). Use Date.prototype.toISOString() to return a string in yyyy-mm-dd format.
const tomorrow = () => { let t = new Date(); t.setDate(t.getDate() + 1); - const ret = `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, '0')}-${String( - t.getDate() - ).padStart(2, '0')}`; - return !long ? ret : `${ret}T00:00:00`; + return t.toISOString().split('T')[0]; }; -
tomorrow(); // 2017-12-27 (if current date is 2017-12-26) -tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26) +
tomorrow(); // 2018-10-18 (if current date is 2018-10-18)