Better time parsing and stuff

Sounds like some people might have already done this locally but here's a pull request for it anyway.

Plus some improved code formatting, because everyone likes PEP8 compliance.