Migrate time code from https://github.com/DataValues/Common