forked from bitbucket and updating localtime method to be tz-aware-friendly