feat: Standardize audit log timestamps to UTC in the backend and display local time in the frontend.
This commit is contained in:
@@ -114,13 +114,19 @@
|
||||
handleFilterChange();
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string): string {
|
||||
function formatDate(dateStr: string, timestamp?: string): string {
|
||||
if (timestamp) {
|
||||
return new Date(timestamp).toLocaleDateString();
|
||||
}
|
||||
if (!dateStr) return '';
|
||||
const [y, m, d] = dateStr.split('-');
|
||||
return `${d}/${m}/${y}`;
|
||||
}
|
||||
|
||||
function formatTime(timeStr: string): string {
|
||||
function formatTime(timeStr: string, timestamp?: string): string {
|
||||
if (timestamp) {
|
||||
return new Date(timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
if (!timeStr) return '';
|
||||
try {
|
||||
const [h, m] = timeStr.split(':');
|
||||
@@ -316,8 +322,8 @@
|
||||
<Table.Cell class="text-sm">{log.procedure}</Table.Cell>
|
||||
<Table.Cell class="text-sm">{log.movement}</Table.Cell>
|
||||
<Table.Cell class="text-sm">{log.username}</Table.Cell>
|
||||
<Table.Cell class="text-sm">{formatDate(log.date)}</Table.Cell>
|
||||
<Table.Cell class="text-sm">{formatTime(log.time)}</Table.Cell>
|
||||
<Table.Cell class="text-sm">{formatDate(log.date, log.timestamp)}</Table.Cell>
|
||||
<Table.Cell class="text-sm">{formatTime(log.time, log.timestamp)}</Table.Cell>
|
||||
</Table.Row>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user