1 | import moment from 'moment';
|
2 |
|
3 | import toMomentObject from './toMomentObject';
|
4 |
|
5 | export default function toISOMonthString(date, currentFormat) {
|
6 | const dateObj = moment.isMoment(date) ? date : toMomentObject(date, currentFormat);
|
7 | if (!dateObj) return null;
|
8 |
|
9 | // Template strings compiled in strict mode uses concat, which is slow. Since
|
10 | // this code is in a hot path and we want it to be as fast as possible, we
|
11 | // want to use old-fashioned +.
|
12 | // eslint-disable-next-line prefer-template
|
13 | return dateObj.year() + '-' + String(dateObj.month() + 1).padStart(2, '0');
|
14 | }
|