Created
October 9, 2014 06:15
-
-
Save simongong/555231b2320965e50502 to your computer and use it in GitHub Desktop.
JavaScirpt: some helper functions with moment.js
This file contains hidden or 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
/* | |
@param | |
date: '2014-01' | |
@return | |
'2014-02' | |
*/ | |
function getNextMonth(date){ | |
var current = moment(date).month(); | |
return moment(date).month(current + 1).format("YYYY-MM"); | |
} | |
/* | |
@param | |
date: '2014-01' | |
@return | |
'2013-12' | |
*/ | |
function getPreviousMonth(date){ | |
var current = moment(date).month(); | |
return moment(date).month(current - 1).format("YYYY-MM"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment