from datetime import datetime


def datetime_from_millis(x):
    """Convert milliseconds since the epoch to a naive `datetime.datetime`"""
    if x is None or x == 0:
        return None
    return datetime.fromtimestamp(x / 1e3)