fix: use timezone offset when grouping operations in OperationTree

This commit is contained in:
Gareth George
2023-12-21 00:49:21 +00:00
parent 48d80b9473
commit 06240bd7ad
2 changed files with 16 additions and 5 deletions
+4 -5
View File
@@ -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) => {
+12
View File
@@ -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") {