You could change that last elseif to just else and remove the else at the end of the code, as the if/elseif statements, in that order, cover all 24 hours of the day.
Well, I put that extra else statement, for in case people altered their default ctcp time reply. In that case $5 could be anything.
The var %timereply can be removed though, I only used it for testing the reply and forgot to remove it.