| | |
| | | if (val > 2958465 || val <= 0) { // 时间过大或小于等于0 |
| | | errors.push(_position + dict['main.excel.content.date.over']) |
| | | } else { // 时间格式化 |
| | | val = this.formatExcelDate(val) |
| | | if (val < 60) { // 1900-2-29,excel中存在,实际不存在 |
| | | val++ |
| | | } |
| | | val = moment('19000101', 'YYYYMMDD').add(Math.floor(val - 2), 'days').format('YYYY-MM-DD') |
| | | } |
| | | } else if (typeof(val) === 'string') { |
| | | val = val.replace(/(^\s*$)|\t*|\v*/ig, '') |
| | |
| | | bottom: _sqlBottom, |
| | | errors: errors.join('; ') |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 格式化excel中的date值 |
| | | * @param {Number} number 时间值 |
| | | */ |
| | | static formatExcelDate(number) { |
| | | if (number < 60) { // 1900-2-29,excel中存在,实际不存在 |
| | | number++ |
| | | } |
| | | |
| | | return moment('19000101', 'YYYYMMDD').add(number - 2, 'days').format('YYYY-MM-DD') |
| | | // const time = new Date((number - 25569) * 24 * 3600000) |
| | | // time.setYear(time.getFullYear() - 70) |
| | | // const year = time.getFullYear() |
| | | // const month = time.getMonth() + 1 |
| | | // const date = time.getDate() - 1 |
| | | |
| | | // return `${year}-${(month < 10 ? '0' + month : month)}-${(date < 10 ? '0' + date : date)}` |
| | | } |
| | | |
| | | /** |