### What problem does this PR solve? Fix: Optimized the timeline component and parser editing features #9869 - Introduced the TimelineNodeType type, restructured the timeline node structure, and supported dynamic node generation - Enhanced the FormatPreserveEditor component to support editing and line wrapping of JSON-formatted content - Added a rerun function and loading state to the parser and splitter components - Adjusted the timeline style and interaction logic to enhance the user experience - Improved the modal component and added a destroy method to support more flexible control - Optimized the chunk result display and operation logic, supporting batch deletion and selection ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
63 lines
1.3 KiB
TypeScript
63 lines
1.3 KiB
TypeScript
import dayjs from 'dayjs';
|
|
import { toFixed } from './common-util';
|
|
|
|
export function formatDate(date: any) {
|
|
if (!date) {
|
|
return '';
|
|
}
|
|
return dayjs(date).format('DD/MM/YYYY HH:mm:ss');
|
|
}
|
|
|
|
export function formatTime(date: any) {
|
|
if (!date) {
|
|
return '';
|
|
}
|
|
return dayjs(date).format('HH:mm:ss');
|
|
}
|
|
|
|
export function today() {
|
|
return formatDate(dayjs());
|
|
}
|
|
|
|
export function lastDay() {
|
|
return formatDate(dayjs().subtract(1, 'days'));
|
|
}
|
|
|
|
export function lastWeek() {
|
|
return formatDate(dayjs().subtract(1, 'weeks'));
|
|
}
|
|
|
|
export function formatPureDate(date: any) {
|
|
if (!date) {
|
|
return '';
|
|
}
|
|
return dayjs(date).format('DD/MM/YYYY');
|
|
}
|
|
|
|
export function formatStandardDate(date: any) {
|
|
if (!date) {
|
|
return '';
|
|
}
|
|
const parsedDate = dayjs(date);
|
|
if (!parsedDate.isValid()) {
|
|
return '';
|
|
}
|
|
return parsedDate.format('YYYY-MM-DD');
|
|
}
|
|
|
|
export function formatSecondsToHumanReadable(seconds: number): string {
|
|
if (isNaN(seconds) || seconds < 0) {
|
|
return '0s';
|
|
}
|
|
|
|
const h = Math.floor(seconds / 3600);
|
|
const m = Math.floor((seconds % 3600) / 60);
|
|
const s = toFixed(seconds % 60, 3);
|
|
|
|
const parts = [];
|
|
if (h > 0) parts.push(`${h}h`);
|
|
if (m > 0) parts.push(`${m}m`);
|
|
if (s || parts.length === 0) parts.push(`${s}s`);
|
|
|
|
return parts.join('');
|
|
}
|