Fixing portability issue with timestamp creation

If long is 32-bits, then uint32 -> long can have undefined behavior. Now
keeping seconds in long format when calculating fractional portion.