def get_point_of_reference()

in curator/helpers/date_ops.py [0:0]


def get_point_of_reference(unit, count, epoch=None):
    """
    :param unit: One of ``seconds``, ``minutes``, ``hours``, ``days``, ``weeks``,
        ``months``, or ``years``.
    :param unit_count: The number of ``units``. ``unit_count`` * ``unit`` will be
        calculated out to the relative number of seconds.
    :param epoch: An epoch timestamp used in conjunction with ``unit`` and
        ``unit_count`` to establish a point of reference for calculations.

    :type unit: str
    :type unit_count: int
    :type epoch: int

    :returns: A point-of-reference timestamp in epoch + milliseconds by deriving from a
        ``unit`` and a ``count``, and an optional reference timestamp, ``epoch``
    :rtype: int
    """
    if unit == 'seconds':
        multiplier = 1
    elif unit == 'minutes':
        multiplier = 60
    elif unit == 'hours':
        multiplier = 3600
    elif unit == 'days':
        multiplier = 3600 * 24
    elif unit == 'weeks':
        multiplier = 3600 * 24 * 7
    elif unit == 'months':
        multiplier = 3600 * 24 * 30
    elif unit == 'years':
        multiplier = 3600 * 24 * 365
    else:
        raise ValueError(f'Invalid unit: {unit}.')
    # Use this moment as a reference point, if one is not provided.
    if not epoch:
        epoch = time.time()
    epoch = fix_epoch(epoch)
    return epoch - multiplier * count