Fixed a bug with time range detection.

There was a logical error in handling wrap-around times ranges.
I've fixed it, and added some loggin to the server code.