Convert a millisecond time value to an offset-aware Python datetime object.

def ms_to_datetime(ms, tzinfo=None):
    """Convert a millisecond time value to an offset-aware Python datetime object."""
    if not isinstance(ms, (int, long)):
        raise TypeError('expected integer, not %s' % type(ms))

    if tzinfo is None:
        tzinfo = mktz()

    return datetime.datetime.fromtimestamp(ms * 1e-3, tzinfo)