Avoid compiler warning that complains about comparing signed and unsigned integer.
Write ts value only if it has been set.