Integrate a periodic absolute value function \begin{equation}
\int_{0}^t \left|\cos(t)\right|dt = \sin\left(t-\pi\left\lfloor{\frac{t}{\pi}+\frac{1}{2}}\right\rfloor\right)+2\left\lfloor{\frac{t}{\pi}+\frac{1}{2}}\right\rfloor
\end{equation}
I got the above integral from https://www.physicsforums.com/threads/closed-form-integral-of-abs-cos-x.761872/. It seems to hold and the way I approached it was to see that the integrand was periodic and $\int_{\frac{\pi}{2}}^\frac{3\pi}{2} -\cos(t)dt=\int_{\frac{3\pi}{2}}^{\frac{5\pi}{2}} \cos(t)dt=\ldots=2$.
I need to evaluate a similar integral.
\begin{equation}
\int_{0}^t \sin\left(\frac{1}{2}(s-t)\right)\left|\sin\left(\frac{1}{2}s\right)\right|ds
\end{equation}
Here too the integrand is periodic but I am unable to get the closed form. Can someone help me out?

A quick experimentation gave me that
$$
\int_0^t\sin\left(\frac{s-t}{2}\right)\left|\sin\left(\frac{s}{2}\right)\right|\,\mathrm{d}s=
\mathrm{sign}\left(-\sin \left(\frac{t}{2}\right)\right) \left(2 \pi  \cos \left(\frac{t}{2}\right) \left\lceil \frac{\left\lfloor \frac{t}{2 \pi }\right\rfloor }{2}\right\rceil +\sin \left(\frac{t}{2}\right)-\frac{1}{2} t \cos \left(\frac{t}{2}\right)\right)$$
This is by no means the only closed form, and it probably isn't nice enough for what you are looking for, so please accept my apologies.
Hope this helps.
