Given a POSIX timestamp (integer) ``t``,
    format it as a datetime string in the given format.
    If ``inverse``, then do the inverse, that is, assume ``t`` is
    a datetime string in the given format and return its corresponding
    timestamp.
    If ``format is None``, then return ``t`` as a string
    (if not ``inverse``) or as an integer (if ``inverse``) directly.

def timestamp_to_str(t, datetime_format=DATETIME_FORMAT, *, inverse=False):
    """
    Given a POSIX timestamp (integer) ``t``,
    format it as a datetime string in the given format.
    If ``inverse``, then do the inverse, that is, assume ``t`` is
    a datetime string in the given format and return its corresponding
    timestamp.
    If ``format is None``, then return ``t`` as a string
    (if not ``inverse``) or as an integer (if ``inverse``) directly.
    """
    if not inverse:
        if datetime_format is None:
            result = str(t)
        else:
            result = dt.datetime.fromtimestamp(t).strftime(datetime_format)
    else:
        if format is None:
            result = int(t)
        else:
            result = dt.datetime.strptime(t, datetime_format).timestamp()
    return result