In electrified railways, the train generates substantial regenerative braking energy (RBE) during braking mode. Deploying wayside hybrid energy storage systems (HESSs) offers a promising solution for recovering and reusing this energy. However, due to the highly fluctuating nature of train power, existing methods based on fixed timescales often struggle to achieve an effective tradeoff between computational efficiency and modeling accuracy. To resolve these limitations, this article proposes a novel operation approach for HESS based on a variable-timebox model. First, a variable-timebox model is constructed, in which the charging and discharging durations of HESS are treated as decision variables. The model simultaneously optimizes RBE recovery and battery capacity degradation by considering the depth of discharge (DoD). Second, to determine the reasonable duration range, a temporal clustering method is proposed. A change point detection (CPD) strategy based on an improved cumulative sum (CUSUM) algorithm is employed to identify characteristics of the traction load. Finally, the effectiveness of the proposed method is validated using real-world data. The simulation results demonstrate that the proposed method reduces computation time by more than 60% while maintaining modeling accuracy.