strptime bug

Thanks to @sebres with #720 for highlighting. Most changes are reverts from #349 which was merged in #368. I believe this is now correct, put please give this through review :smile: