"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getDefaultDateOfCycle = getDefaultDateOfCycle;

var _moment = _interopRequireDefault(require("moment"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function getDefaultDateOfCycle(cycle) {
  switch (cycle.cycleType) {
    case '1':
      {
        return {
          startDate: "".concat(cycle.annualNum, "/01/01"),
          endDate: "".concat(cycle.annualNum, "/12/31")
        };
      }

    case '2':
      {
        var quarter = (0, _moment["default"])().set('year', Number(cycle.annualNum)).set('quarter', Number(cycle.yqmNum));
        return {
          startDate: quarter.startOf('quarter').format('YYYY/MM/DD'),
          endDate: quarter.endOf('quarter').format('YYYY/MM/DD')
        };
      }

    case '3':
      {
        return {
          startDate: "".concat(cycle.annualNum, "/").concat(cycle.yqmNum < 10 ? '0' + cycle.yqmNum : cycle.yqmNum, "/01"),
          endDate: (0, _moment["default"])(cycle.annualNum + '/' + cycle.yqmNum + '/' + 1).add(1, 'month').set('date', 0).format('YYYY/MM/DD')
        };
      }

    default:
      {
        return {
          startDate: (0, _moment["default"])().format('YYYY/MM/DD'),
          endDate: (0, _moment["default"])().add(30, 'day').format('YYYY/MM/DD')
        };
      }
  }
}