feat: add createdAt timestamps to check-in logs and improve i18n translations

- Added createdAt timestamps to various check-in log entries in checkinService.ts for better tracking.
- Updated i18n translations in Models.tsx to improve user experience with accurate Chinese translations.
- Reduced default page size in ProgramLogs.tsx and ProxyLogs.tsx from 80 and 100 to 50 for better performance.
- Enhanced ProxyLogs.tsx with memoization for filtered logs and summary statistics.
- Implemented support for parsing Unix timestamps and PostgreSQL-style timezone offsets in checkinLogTime.ts.
- Added comprehensive tests for database proxy query wrapper in index.proxy-wrap.test.ts to ensure functionality.
This commit is contained in:
cita
2026-03-05 21:18:49 +08:00
parent 0d5e56f478
commit fdf4f30987
19 changed files with 313 additions and 156 deletions
@@ -19,4 +19,13 @@ describe('formatCheckinLogTime', () => {
expect(formatDateLocal('2026-02-25 03:51:58', 'en-US', 'UTC')).toBe('02/25/2026');
expect(formatDateTimeMinuteLocal('2026-02-25 03:51:58', 'en-US', 'UTC')).toBe('02/25/2026, 03:51');
});
it('supports postgres-style timezone offset without colon', () => {
expect(formatDateTimeMinuteLocal('2026-03-05 20:14:39+08', 'en-US', 'UTC')).toBe('03/05/2026, 12:14');
expect(formatDateTimeMinuteLocal('2026-03-05T20:14:39+0800', 'en-US', 'UTC')).toBe('03/05/2026, 12:14');
});
it('supports unix timestamp strings', () => {
expect(formatDateTimeMinuteLocal('1709640000', 'en-US', 'UTC')).toBe('03/05/2024, 12:00');
});
});
+13
View File
@@ -4,10 +4,23 @@ function parseServerUtcDate(value: string | null | undefined): { date: Date | nu
const raw = String(value).trim();
if (!raw) return { date: null, raw };
if (/^\d{10,13}$/.test(raw)) {
const asNumber = Number(raw);
if (Number.isFinite(asNumber)) {
const epochMs = raw.length === 13 ? asNumber : asNumber * 1000;
const date = new Date(epochMs);
if (!Number.isNaN(date.getTime())) {
return { date, raw };
}
}
}
let normalized = raw;
if (!normalized.includes('T') && normalized.includes(' ')) {
normalized = normalized.replace(' ', 'T');
}
normalized = normalized.replace(/([+-]\d{2})(\d{2})$/, '$1:$2');
normalized = normalized.replace(/([+-]\d{2})$/, '$1:00');
const hasTimeZone = /[zZ]$|[+-]\d{2}:\d{2}$/.test(normalized);
if (!hasTimeZone) {