  We develop an It\^o calculus for functionals of the "time" spent by a path at
arbitrary levels. A Markovian setting is recovered by lifting a process $X$
with its flow of occupation measures $\mathcal{O}$ and call the pair
$(\mathcal{O},X)$ the occupied process. While the occupation measure erases the
chronology of the path, we show that our framework still includes many relevant
problems in stochastic analysis and financial mathematics. The study of
occupied processes therefore strikes a middle ground between the
path-independent case and Dupire's Functional It\^o Calculus. We extend It\^o's
and Feynman-Kac's formula by introducing the occupation derivative, a
projection of the functional linear derivative used extensively in mean field
games and McKean-Vlasov optimal control. Importantly, we can recast through
Feynman-Kac's theorem a large class of path-dependent PDEs as parabolic
problems where the occupation measure plays the role of time. We apply the
present tools to the optimal stopping of spot local time and discuss financial
examples including exotic options, corridor variance swaps, and path-dependent
volatility.
