Move large section of update check code into its own function

Thanks to M. Reza for reporting a difficult-to-reproduce bug during
update checks.  For reasons unknown (possibly certain locale
settings??), the DateDiff() function will sometimes experience type
mismatches, despite all provided dates being valid.

Rather than trying to find an in-depth solution, I've simply moved that
batch of code into its own function and added error handling.