Calculate next day cutoff correctly

The previous code was manipulating time spans by hand, which was causing inaccuracies. This change incorporates use of GregorianCalendar, which is sensitive to various changes in time, such a leap years, daylight savings, and more.