Made the parsing of timestamps more flexible.

The previous function would fail if the incoming date was not in exactly the right format.