Add a routine to return a diff between two dates in seconds
Use the routine that calculates time difference in seconds, and move the check for Network availability after the check for the time.