Calculating the integral with an indicator function

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) = \int\limits_{\max\{0, ~t-1\}}^{\min\{1,~ t\}}x \cdot \mathbf 1_{0 \le t-x \le 1}~\mathrm dx = \begin{cases}\displaystyle\int_0^t x ~\mathrm dx = \frac{t^2}{2}, & t \le 1 \\[2mm] \displaystyle\int_{t-1}^1 x ~ \mathrm dx = \frac{2t - t^2}{2}, & t > 1\end{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 integral comes from a probability problem

Your result is correct, but there is a bit of imprecision in your work, since you cannot write the limits of integration as simply $$\max(0, t-1)$$ and $$\min(1, t)$$. Rather, they would need to be written as $$\min(\max(0, t-1), 1), \quad \max(\min(1, t), 0).$$