Skip to content

Instantly share code, notes, and snippets.

@authenticsebastian
Last active February 12, 2018 11:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save authenticsebastian/0aa1df035cfce097cef3aa174d73c5c4 to your computer and use it in GitHub Desktop.
Save authenticsebastian/0aa1df035cfce097cef3aa174d73c5c4 to your computer and use it in GitHub Desktop.
Calculating how many months have passed since given date
const monthsLater = (date, months) =>
[
(dateArg) => new Date(dateArg),
(dateObj) => dateObj.setMonth(dateObj.getMonth() + months),
(timestamp) => new Date(timestamp),
String
].reduce(
(value, fn) => fn(value),
date
);
@authenticgaming-redeemerpace

Amazing :o seems I inspired you on how many months I've been working :)

@authenticsebastian
Copy link
Author

Laziness sometimes get the best of us.

@authenticgaming-redeemerpace

Best programmers are a bit lazy, because they try to invent something to not do it themselves repetitively :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment