Implement timedeltas for to_json

Closes #9027
maybe add a Timestamp in there as well for the test?