Perhaps better to use `if timestr.endswith('Z'):` so that if the user supplies an empty string it doesn't get a confusing IndexError here.  (It will die later, but with hopefully a reasonable error message).