I am under the impression that your code assumes that the difference between current_clock and prev_clock is normally always 1. Is this correct ?
This is not the case, and can't be, because this function can be called anytime and it can elapse minutes (or hours) between two successive calls, and thus the current_clock and prev_clock variables could differ greatly. And time_in_seconds wouldn't have been updated since last call, and thus would be completely obsolete.
There may be something I don't understand, but to me it seems your code is heavily buggy
