Better handling of day changing

Ref issue #1