Initial Python implementation of datetime encoding