import moment from 'moment'; function today() { return __DEV__ ? '2020-06-17 00:00:00,2020-06-17 23:59:59' : moment().format('YYYY-MM-DD') + ' 00:00:00,' + moment().add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00'; } function getSearchDate(showDate) { return ( showDate + ' 00:00:00,' + moment(showDate, 'yyyy-MM') .add(1, 'months') .add(-1, 'seconds') .format('yyyy-MM-DD') + ' 23:59:59' ); } class MonthDate { constructor() { var list = []; for (let i = 0; i < 6; i++) { list.push( moment() .add(0 - i, 'months') .format('yyyy-MM') ); } this.showList = list; } } function parse(date, formatStr = 'yyyy-MM-DD HH:mm:ss') { return moment(date, formatStr); } function getChatTime(date, formatStr = 'yyyy-MM-DD HH:mm:ss') { if (parse(date).format('yyyy-MM-DD') === moment().format('yyyy-MM-DD')) { return parse(date).format('HH:mm'); } else { return parse(date).format('MM-DD HH:mm'); } } export { today, MonthDate, getSearchDate, parse, getChatTime };