Implement timedeltas for to_json

Closes #9027
see ``tslib.pyx/total_seconds`` (exists for exactly the same reason)