Is a function which is locally of bounded variation everywhere the difference of two monotone functions? This is related to this question, but simpler: Bounded variation, difference of two increasing functions
We call a function $f: \mathbb{R} \to \mathbb{R}$ locally of bounded variation if it is of bounded variation for every compact interval $[c,d]$. (To the best of my knowledge -- please correct me if this is false.)
It is known that any function of bounded variation on a compact interval is the difference of monotone functions.
My question: can we glue together these two monotone functions for every $[n,n+1], n \in \mathbb{Z}$ to show that every function which is locally of bounded variation is the difference of two monotone functions $g,h: \mathbb{R}$? Or is the best we can do is piecewise monotone?
 A: Yes, we can glue these monotone functions together. It is enough to show that we can glue together two monotone functions, the result will follow inductively. Suppose we have $a < b < c$, and $f : [a, c] \to \mathbb{R}$, such that $f = g'-h'$ on $[a, b]$ and $f = g''-h''$ on $[b, c]$. Now we know that $f = (g''+\delta)-(h''+\delta)$ for any constant $\delta$, most importantly for $n = g'(b)-g''(b) = h'(b)-h''(b)$.
Now define $$g : [a, c] \to \mathbb{R},~~ x \mapsto \begin{cases}g'(x) & x \leq b \\ g''(x) - g''(b) + g'(b) & x \geq b \end{cases}$$
and analogously $h$. Now $g$ and $h$ are monotone by construction, and we have $f = g - h$ on $[a, c]$. As an important note, we have $g = g'$ and $h = h'$ on $[a, b]$. We could have modified the construction to ensure $g = g''$ and $h = h''$ on $[b, c]$.
With this method of gluing together local representations of $f$, using the fact that every open covering of a compact space has a finite subcovering, we can show that $f$ is of bounded variation (in particular the difference of bounded monotone functions) on any compact interval.
Now for all $n \in \mathbb{N}$ let us inductively construct monotone $g_n, h_n : [-n, n] \to \mathbb{R}$ such that $f = g_n - h_n$ and $g_n = g_{n-1}$ and $h_n = h_{n-1}$ wherever both sides are defined. We do this by using the fact that $[-n, n] = [-n, -n+1] \cup [-n+1, n-1] \cup [n-1, n]$: construct $g_n$ and $h_n$ by extending $g_{n-1}$ and $h_{n-1}$ respectively.
Now define $g(x) := g_n(x), h(x) := h_n(x)$ pointwise, using any $n$ for which $g_n(x)$ and $h_n(x)$ are defined. We receive monotone (but not necessarily bounded) $g, h : \mathbb{R} \to \mathbb{R}$ such that $f = g - h$.
A: Using the construction from the post you cited, we can't simply glue together the functions from different intervals because, adopting the notation from the aforementioned post, if on $[n,n+1)$ $F(x):=Var[n,x]$ then $F(n)=0$ but $F(n)$ defined on $[n-1,n)$ will not generically tend to $0$. Thus, we have to be a little careful as to how we glue the functions together, but by shifting our functions accordingly we see that this isn't much of an obstruction. In particular:
Adopting the notation from the aforementioned post, for $n\geq0$ let $$F(x)\vert_{[n,n+1)}=:F_n(x)=Var[n,x]+\sum_{i=1}^nVar[i-1,i]$$ For $n<0$ let $$F(x)\vert_{[n,n+1)}=:F_n(x)=Var[n,x]-\sum_{i=-n}^{-1}Var[i,i+1]$$.
