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.5KB

123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. 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"); } }; }();
  6. var _pad = require('./pad');
  7. var _pad2 = _interopRequireDefault(_pad);
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * @param {String} value YYYY-MM format
  11. * @param {Number} sign -1 or +1
  12. */
  13. exports.default = function (value, sign) {
  14. var _value$split$map = value.split('-').map(Number),
  15. _value$split$map2 = _slicedToArray(_value$split$map, 2),
  16. year = _value$split$map2[0],
  17. month = _value$split$map2[1];
  18. if (month + sign === 0) {
  19. return year - 1 + '-12';
  20. } else if (month + sign === 13) {
  21. return year + 1 + '-01';
  22. } else {
  23. return year + '-' + (0, _pad2.default)(month + sign);
  24. }
  25. };
  26. //# sourceMappingURL=monthChange.js.map