# Path: src/bepasty/constants.py
# FOREVER = -1
# 
# TIMESTAMP_MAX_LIFE = 'timestamp-max-life'


import time
from flask import current_app
from werkzeug.exceptions import BadRequest
from ..constants import FOREVER, TIMESTAMP_MAX_LIFE
    unit_key = 'maxlife_unit' if underscore else 'maxlife-unit'
    unit_default = 'MONTHS'
    unit = data.get(unit_key, unit_default).upper()
    value_key = 'maxlife_value' if underscore else 'maxlife-value'
    value_default = '1'
    try:
        value = int(data.get(value_key, value_default))
    except (ValueError, TypeError):
        raise BadRequest(description=f'{value_key} header is incorrect')
    try:
        return time_unit_to_sec(value, unit)
    except KeyError:
        raise BadRequest(description=f'{unit_key} header is incorrect')


def time_unit_to_sec(value, unit):
    """
    Converts a numeric value and with a string time unit unit to a time in seconds

    :param value: int
    :param unit: str in ['MINUTES', 'HOURS', 'DAYS', 'WEEKS', 'MONTHS', 'YEARS', 'FOREVER']
    :return: time in seconds
    """
    units = {
        'MINUTES': 60,
        'HOURS': 60 * 60,
        'DAYS': 60 * 60 * 24,
        'WEEKS': 60 * 60 * 24 * 7,
        'MONTHS': 60 * 60 * 24 * 30,
        'YEARS': 60 * 60 * 24 * 365,

# Path: src/bepasty/constants.py
# FOREVER = -1
# 
# TIMESTAMP_MAX_LIFE = 'timestamp-max-life'


# Path: src/bepasty/utils/date_funcs.py
import time
from flask import current_app
from werkzeug.exceptions import BadRequest
from ..constants import FOREVER, TIMESTAMP_MAX_LIFE

    unit_key = 'maxlife_unit' if underscore else 'maxlife-unit'
    unit_default = 'MONTHS'
    unit = data.get(unit_key, unit_default).upper()
    value_key = 'maxlife_value' if underscore else 'maxlife-value'
    value_default = '1'
    try:
        value = int(data.get(value_key, value_default))
    except (ValueError, TypeError):
        raise BadRequest(description=f'{value_key} header is incorrect')
    try:
        return time_unit_to_sec(value, unit)
    except KeyError:
        raise BadRequest(description=f'{unit_key} header is incorrect')


def time_unit_to_sec(value, unit):
    """
    Converts a numeric value and with a string time unit unit to a time in seconds

    :param value: int
    :param unit: str in ['MINUTES', 'HOURS', 'DAYS', 'WEEKS', 'MONTHS', 'YEARS', 'FOREVER']
    :return: time in seconds
    """
    units = {
        'MINUTES': 60,
        'HOURS': 60 * 60,
        'DAYS': 60 * 60 * 24,
        'WEEKS': 60 * 60 * 24 * 7,
        'MONTHS': 60 * 60 * 24 * 30,
        'YEARS': 60 * 60 * 24 * 365,

        'FOREVER': FOREVER,