(time, type)
| 17 | * @return {String} |
| 18 | */ |
| 19 | export default function dataTimeFormatter(time, type) { |
| 20 | let date = new Date(time) |
| 21 | let year = date.getFullYear() |
| 22 | let month = date.getMonth() + 1 |
| 23 | let day = date.getDate() |
| 24 | let hours = date.getHours() |
| 25 | let minutes = date.getMinutes() |
| 26 | let second = date.getSeconds() |
| 27 | |
| 28 | switch (type) { |
| 29 | case 0: // 01-05 |
| 30 | return `${zerofill(month)}-${zerofill(day)}` |
| 31 | case 1: // 11:12 |
| 32 | return `${zerofill(hours)}-${zerofill(minutes)}` |
| 33 | case 2: // 2015-01-05 |
| 34 | return `${year}-${zerofill(month)}-${zerofill(day)}` |
| 35 | case 3: // 2015-01-05 11:12 |
| 36 | return `${year}-${zerofill(month)}-${zerofill(day)} ${zerofill(hours)}:${zerofill(minutes)}` |
| 37 | default: // 2015-01-05 11:12:13 |
| 38 | return `${year}-${zerofill(month)}-${zerofill(day)} ${zerofill(hours)}:${zerofill(minutes)}:${zerofill(second)}` |
| 39 | } |
| 40 | } |
nothing calls this directly
no test coverage detected