move to .py
simplify date encoding