I’m having a problem calculating

$$f(t) = int_0^1 x cdot mathbf 1_{0 le t-x le 1}~mathrm dx$$

The indicator inequality implies $t-1 le x le t$. Firstly, if $t le 0$, then $t – x le 0$ so $f(t) = 0$. Similarly, $f(t) = 0$ when $t > 2$. Now we are left with $t in (0,2)$. We now have

$$f(t) = intlimits_{max{0, ~t-1}}^{min{1,~ t}}x cdot mathbf 1_{0 le t-x le 1}~mathrm dx =

begin{cases}displaystyleint_0^t x ~dx = frac{t^2}{2}, & t le 1 \(2mm)

displaystyleint_{t-1}^1 x ~ dx = frac{2t – t^2}{2}, & t > 1end{cases}$$

Therefore,

$$f(t) = begin{cases}0, & t in (-infty, 0) cup (2,+infty) \(2mm)

dfrac{t^2}{2}, & t in (0,1) \(2mm)

dfrac{2t-t^2}{2}, & t in (1, 2)end{cases}$$

Is this correct?

_{ Note: I am adding the probability tag because this problem comes from a probability problem}