Restrict special datetime handling to parts of messages

This is an alternate implementation of #826.
It seems like it would be cleaner to construct a real message object from the payload and then call ``msg.to_json()``?