Made datetime encoding and decoding overridable and extensible