import { strategyMap, weekdayMap } from '@/const'
import moment from 'moment'
export default {
  filters: {
    strategyName (value) {
      return strategyMap.find(i => i.value === value).label
    },
    duration (value) {
      var d = moment.duration(value, 'seconds')
      var hours = Math.floor(d.asHours())
      var mins = Math.floor(d.asMinutes()) - hours * 60
      var seconds = Math.floor(d.asSeconds()) - hours * 60 * 60 - mins * 60
      return String(hours).padStart(2, '0') + ':' + String(mins).padStart(2, '0') + ':' + String(seconds).padStart(2, '0')
    }
  },
  methods: {
    formatPeriod (arr) {
      return arr.map(i => {
        return i.start + ' ~ ' + i.end
      }).join('、')
    },
    formatWeekday (arr) {
      return arr.map(i => {
        return weekdayMap[i]
      }).join('、')
    }
  }
}
