(fmt)
| 155 | } |
| 156 | // 获取时间 fmt传格式如 'yyyy-MM-dd HH:mm:ss' |
| 157 | export function getNowTime (fmt) { |
| 158 | const date = new Date(); |
| 159 | const o = { |
| 160 | 'M+': date.getMonth() + 1, // 月份 |
| 161 | 'd+': date.getDate(), // 日 |
| 162 | 'H+': date.getHours(), // 小时 |
| 163 | 'm+': date.getMinutes(), // 分 |
| 164 | 's+': date.getSeconds(), // 秒 |
| 165 | 'q+': Math.floor((date.getMonth() + 3) / 3), // 季度 |
| 166 | S: date.getMilliseconds(), // 毫秒 |
| 167 | }; |
| 168 | if (/(y+)/.test(fmt)) |
| 169 | fmt = fmt.replace(RegExp.$1, `${date.getFullYear()}`.substr(4 - RegExp.$1.length)); |
| 170 | for (const k in o) |
| 171 | if (new RegExp(`(${k})`).test(fmt)) |
| 172 | fmt = fmt.replace( |
| 173 | RegExp.$1, |
| 174 | RegExp.$1.length == 1 ? o[k] : `00${o[k]}`.substr(`${o[k]}`.length), |
| 175 | ); |
| 176 | return fmt; |
| 177 | } |
| 178 | // blob 转base64 |
| 179 | export function blobToBase64 (blob) { |
| 180 | return new Promise((resolve, reject) => { |
nothing calls this directly
no outgoing calls
no test coverage detected