diff --git a/README.md b/README.md index dd825ad0c..64f30f95d 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,6 @@ average(1, 2, 3); * [`formatDuration`](#formatduration) * [`getDaysDiffBetweenDates`](#getdaysdiffbetweendates) -* [`toEnglishDate`](#toenglishdate) * [`tomorrow`](#tomorrow) @@ -2547,36 +2546,6 @@ getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')); // 9
[⬆ Back to top](#table-of-contents) -### toEnglishDate - -Converts a date from American format to English format. - -Use `Date.toISOString()`, `split('T')` and `replace()` to convert a date from American format to the English format. -Throws an error if the passed time cannot be converted to a date. - -```js -const toEnglishDate = time => { - try { - return new Date(time) - .toISOString() - .split('T')[0] - .replace(/-/g, '/'); - } catch (e) {} -}; -``` - -
-Examples - -```js -toEnglishDate('09/21/2010'); // '21/09/2010' -``` - -
- -
[⬆ Back to top](#table-of-contents) - - ### tomorrow Results in a string representation of tomorrow's date. @@ -5209,6 +5178,7 @@ const httpPost = (url, callback, data = null, err = console.error) => { + const newPost = { "userId": 1, "id": 1337, diff --git a/docs/index.html b/docs/index.html index 3dfa73629..46679e732 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
 
Promise.resolve([1, 2, 3])
   .then(call('map', x => 2 * x))
   .then(console.log); //[ 2, 4, 6 ]
@@ -551,15 +551,6 @@ document.body📋 Copy to clipboard

getDaysDiffBetweenDates

Returns the difference (in days) between two dates.

Calculate the difference (in days) between two Date objects.

const getDaysDiffBetweenDates = (dateInitial, dateFinal) =>
   (dateFinal - dateInitial) / (1000 * 3600 * 24);
 
getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')); // 9
-

toEnglishDate

Converts a date from American format to English format.

Use Date.toISOString(), split('T') and replace() to convert a date from American format to the English format. Throws an error if the passed time cannot be converted to a date.

const toEnglishDate = time => {
-  try {
-    return new Date(time)
-      .toISOString()
-      .split('T')[0]
-      .replace(/-/g, '/');
-  } catch (e) {}
-};
-
toEnglishDate('09/21/2010'); // '21/09/2010'
 

tomorrow

Results in a string representation of tomorrow's date. Use new Date() to get today's date, adding 86400000 of seconds to it(24 hours), using Date.toISOString() to convert Date object to string.

const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0];
 
tomorrow(); // 2017-12-27 (if current date is 2017-12-26)
 

Function

chainAsync

Chains asynchronous functions.

Loop through an array of functions containing asynchronous events, calling next when each asynchronous event has completed.

const chainAsync = fns => {
@@ -1168,6 +1159,7 @@ Logs: {
 
 
 
+
 const newPost = {
   "userId": 1,
   "id": 1337,
diff --git a/snippets/httpPost.md b/snippets/httpPost.md
index 4777f624a..7a52fa2d3 100644
--- a/snippets/httpPost.md
+++ b/snippets/httpPost.md
@@ -25,6 +25,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
 
 
 
+
 const newPost = {
   "userId": 1,
   "id": 1337,
diff --git a/tag_database b/tag_database
index 8487312ed..7eccbefc8 100644
--- a/tag_database
+++ b/tag_database
@@ -165,7 +165,6 @@ takeRight:array
 timeTaken:utility
 toCamelCase:string,regexp
 toDecimalMark:utility,math
-toEnglishDate:date,string
 toggleClass:browser
 toKebabCase:string,regexp
 tomorrow:date