Replace highly inefficent time conversion utility.

Use div() from stdlib, on most machines this will perform division and
modulus in one operation, which is far more efficent than the previous
loop method.