Last active
February 12, 2018 11:23
-
-
Save authenticsebastian/0aa1df035cfce097cef3aa174d73c5c4 to your computer and use it in GitHub Desktop.
Calculating how many months have passed since given date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Best programmers are a bit lazy, because they try to invent something to not do it themselves repetitively :p