1 1
import pad from './pad'
2

3
/**
4
 * @param {String} value YYYY-MM format
5
 * @param {Number} sign -1 or +1
6
 */
7 1
export default (value: string, sign: number) => {
8 1
  const [year, month] = value.split('-').map(Number)
9

10 1
  if (month + sign === 0) {
11 1
    return `${year - 1}-12`
12 1
  } else if (month + sign === 13) {
13 1
    return `${year + 1}-01`
14
  } else {
15 1
    return `${year}-${pad(month + sign)}`
16
  }
17
}

Read our documentation on viewing source code .

Loading