UNPKG

@meta2d/core

Version:

@meta2d/core: Powerful, Beautiful, Simple, Open - Web-Based 2D At Its Best .

21 lines 805 B
export function formatTime(format, utcDate) { const weeks = ['天', '一', '二', '三', '四', '五', '六']; let now = new Date(); if (utcDate) { now = new Date(utcDate); } const year = now.getFullYear(); const month = now.getMonth() + 1; const day = now.getDate(); const week = now.getDay(); const hours = now.getHours(); const minutes = now.getMinutes(); const seconds = now.getSeconds(); let fn = new Function('year', 'month', 'day', 'week', 'hours', 'minutes', 'seconds', format ? `return ${format}` : 'return `${year}:${month}:${day} ${hours}:${minutes}:${seconds} 星期${week}`'); const time = fn(year, month, day, weeks[week], hours, minutes, seconds); fn = null; return time; } //# sourceMappingURL=time.js.map