33 lines
770 B
JavaScript
33 lines
770 B
JavaScript
function formatDateTime(iso) {
|
|
if (!iso || typeof iso !== 'string') return '-';
|
|
// expected format: 2026-03-30T12:34:56
|
|
const s = iso.replace('T', ' ').replace('Z', '');
|
|
if (s.length > 19) return s.slice(0, 19);
|
|
return s;
|
|
}
|
|
|
|
function eventStatusText(status) {
|
|
if (status === 'Enrolling') return '报名中';
|
|
if (status === 'Ongoing') return '比赛中';
|
|
if (status === 'Ended') return '已结束';
|
|
const map = {
|
|
0: '报名中',
|
|
1: '比赛中',
|
|
2: '已结束'
|
|
};
|
|
return map[status] !== undefined ? map[status] : `状态${status}`;
|
|
}
|
|
|
|
function eventFormatText(v) {
|
|
if (v === 'Offline') return '线下';
|
|
if (v === 'Online') return '线上';
|
|
return '';
|
|
}
|
|
|
|
module.exports = {
|
|
formatDateTime,
|
|
eventStatusText,
|
|
eventFormatText
|
|
};
|
|
|