diff --git a/src/app/components/PlanetaryInteraction/PlanetTableRow.tsx b/src/app/components/PlanetaryInteraction/PlanetTableRow.tsx index 368bca8..beb90c8 100644 --- a/src/app/components/PlanetaryInteraction/PlanetTableRow.tsx +++ b/src/app/components/PlanetaryInteraction/PlanetTableRow.tsx @@ -351,8 +351,12 @@ export const PlanetTableRow = ({ const cycleTime = schematic?.cycle_time ?? 3600; const consumptionPerHour = i.quantity * i.factoryCount * (3600 / cycleTime); - // Calculate time until depletion in hours - const hoursUntilDepletion = consumptionPerHour > 0 ? totalAmount / consumptionPerHour : 0; + // Calculate time until depletion in hours, starting from last_update + const lastUpdate = DateTime.fromISO(planet.last_update); + const now = DateTime.now(); + const hoursSinceUpdate = now.diff(lastUpdate, 'hours').hours; + const remainingAmount = Math.max(0, totalAmount - (consumptionPerHour * hoursSinceUpdate)); + const hoursUntilDepletion = consumptionPerHour > 0 ? remainingAmount / consumptionPerHour : 0; return (
0 && ( -
Total: {totalAmount.toFixed(1)} units
+
Total in storage: {totalAmount.toFixed(1)} units
+
Consumption rate: {consumptionPerHour.toFixed(1)} units/hour
+
Last update: {lastUpdate.toFormat('yyyy-MM-dd HH:mm:ss')}
Will be depleted in {hoursUntilDepletion.toFixed(1)} hours
}>