Do time comparison using tm instead of time_t

Avoid int and time_t ambiguity