Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

monthChange.js 1.2KB

12345678910111213141516171819202122
  1. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  2. import pad from './pad';
  3. /**
  4. * @param {String} value YYYY-MM format
  5. * @param {Number} sign -1 or +1
  6. */
  7. export default (function (value, sign) {
  8. var _value$split$map = value.split('-').map(Number),
  9. _value$split$map2 = _slicedToArray(_value$split$map, 2),
  10. year = _value$split$map2[0],
  11. month = _value$split$map2[1];
  12. if (month + sign === 0) {
  13. return year - 1 + '-12';
  14. } else if (month + sign === 13) {
  15. return year + 1 + '-01';
  16. } else {
  17. return year + '-' + pad(month + sign);
  18. }
  19. });
  20. //# sourceMappingURL=monthChange.js.map