You've defined a get_time() function right beneath here which does exactly what we're doing here; that should probably be shared code.