def calculate_delay(current_timestamp: int, previous_timestamp: int) -> int:
    """Returns delay for two unix timestamps"""
    if current_timestamp is None or previous_timestamp is None:
        return 0

    delay = current_timestamp - previous_timestamp
    if delay < 0:
        # It's not possible for the current server to receive the email before previous one
        # It means that either one or both of the servers clocks are off.
        # We assume a delay of 0 in this case
        delay = 0
    return delay