diff --git a/webui/src/components/OperationTree.tsx b/webui/src/components/OperationTree.tsx index ab1b43ef..9761df2e 100644 --- a/webui/src/components/OperationTree.tsx +++ b/webui/src/components/OperationTree.tsx @@ -15,6 +15,7 @@ import { formatDate, formatDuration, formatTime, + localISOTime, normalizeSnapshotId, } from "../lib/formatting"; import { @@ -40,7 +41,6 @@ export const OperationTree = ({ // track backups for this operation tree view. useEffect(() => { - console.log("using effect"); setSelectedBackupId(null); const backupCollector = new BackupInfoCollector(); const lis = (opEvent: OperationEvent) => { @@ -125,7 +125,6 @@ export const OperationTree = ({ setSelectedBackupId(null); return; } - console.log("SELECTED ID: " + backup.id); setSelectedBackupId(backup.id!); }} titleRender={(node: OpTreeNode): React.ReactNode => { @@ -205,7 +204,7 @@ export const OperationTree = ({ const buildTreeYear = (operations: BackupInfo[]): OpTreeNode[] => { const grouped = _.groupBy(operations, (op) => { - return op.displayTime.toISOString().substring(0, 4); + return localISOTime(op.displayTime).substring(0, 4); }); const entries: OpTreeNode[] = _.map(grouped, (value, key) => { @@ -221,7 +220,7 @@ const buildTreeYear = (operations: BackupInfo[]): OpTreeNode[] => { const buildTreeMonth = (operations: BackupInfo[]): OpTreeNode[] => { const grouped = _.groupBy(operations, (op) => { - return op.displayTime.toISOString().substring(0, 7); + return localISOTime(op.displayTime).substring(0, 7); }); const entries: OpTreeNode[] = _.map(grouped, (value, key) => { return { @@ -238,7 +237,7 @@ const buildTreeMonth = (operations: BackupInfo[]): OpTreeNode[] => { const buildTreeDay = (operations: BackupInfo[]): OpTreeNode[] => { const grouped = _.groupBy(operations, (op) => { - return op.displayTime.toISOString().substring(0, 10); + return localISOTime(op.displayTime).substring(0, 10); }); const entries = _.map(grouped, (value, key) => { diff --git a/webui/src/lib/formatting.ts b/webui/src/lib/formatting.ts index 4610c169..493238da 100644 --- a/webui/src/lib/formatting.ts +++ b/webui/src/lib/formatting.ts @@ -34,6 +34,18 @@ export const formatTime = (time: number | string | Date) => { }`; }; +export const localISOTime = (time: number | string | Date) => { + if (typeof time === "string") { + time = parseInt(time); + } else if (time instanceof Date) { + time = time.getTime(); + } + + const d = new Date(); + d.setTime(time - timezoneOffsetMs); + return d.toISOString(); +} + // formatDate formats a time as YYYY-MM-DD export const formatDate = (time: number | string | Date) => { if (typeof time === "string") {