The general solution of $y'=\vert y-t\vert$ 
How to solve the following ODE? $$y' = | y-t |$$

To eliminate the absolute value, I divided the domain into two parts $\{ y(t) > t \}$ and $\{ y(t) < t \}$.


*

*In $\{y(t)>t\}$, the ODE becomes $y'=y-t$. I found $y_+(t)=Ce^t+t+1$. 

*In $\{y(t)<t\}$, the ODE becomes $y'=-y+t$, so the solution is $y_-(t)=Ce^{-t}+t-1$.
How to write the general solution?
 A: The two solutions are indeed separated by the main bissector $y=t$, and are curves asymptotic to the straight lines $y=t\pm1$.
For $C\ge0$ and $y_0\ge1$, $y_+(t)$ is wholly contained above the bissector and is the solution everywhere.
For $C\le0$ and $y_0\le-1$, $y_-(t)$ is wholly contained below the bissector and is the solution everywhere.
For $-1<y_0<1$, the solution is made of two pieces, such that $C_+<0$ and $C_->0$, which meet on the bissector, where they must have equal slopes.
$$\begin{cases}C_+e^t+t+1&=C_-e^{-t}+t-1=t,\\C_+e^t+1&=-C_-e^{-t}+1.\end{cases}$$
The solution is
$$C_+=-e^{-t},C_-=e^{t}$$ for some $t$.
For $y_0\ge0$, $t=-\log(1-y_0)$, and for $y_0\le0$, $t=\log(1+y_0)$. 

A: Look at the sign of $y(t) - t$. When $C\ge 0$, one has $C e^t + 1>0$ for all $t\in R$, hence a first type of solutions
$$
C \ge 0, \forall t\in R, \qquad y(t) = C e^t + t + 1
$$
Similarly, there is a second type of solutions, with $y(t) - t < 0$
$$
C\ge 0, \forall t\in R, \qquad y(t) = -C e^{-t} + t - 1
$$
Now let us look at a solution $-C e^t + t + 1$ (with $C>0$). Such a solution is only defined in $(-\infty, -\log C)$ because $y(t) - t = 0$ when
$t = -\log(C)$. The solution can be continuously extended beyond $-\log C$ with $y(t) = \frac{1}{C}e^{-t} + t - 1$. Hence we get a third kind of
solutions
$$
C>0, \qquad y(t) = \left\{\begin{array} &-C e^t + t + 1,\quad &t\le -\log(C)\cr
\frac{1}{C}e^{-t}+ t - 1,\quad &t\ge -\log(C)\cr\end{array}\right.
$$
