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 (