Exemplo n.º 1
0
    def not_in_future_f(value):
        if is_date(value):
            now = date.today()
        else:
            now = datetime.now(pytz.utc)

        if value > now:
            raise ValidationError("Can't be in the future.")

        return value
Exemplo n.º 2
0
    def before_f(value):
        if is_date(value):
            value_dt = date_to_datetime(value)
        else:
            value_dt = value

        if value_dt > max_dt:
            raise ValidationError('Value is after %s.' % safe_strftime(max_dt, dt_format))

        return value
Exemplo n.º 3
0
    def not_in_future_f(value):
        if is_date(value):
            now = date.today()
        else:
            now = datetime.now(pytz.utc)

        if value > now:
            raise ValidationError("Can't be in the future.")

        return value
Exemplo n.º 4
0
    def before_f(value):
        if is_date(value):
            value_dt = date_to_datetime(value)
        else:
            value_dt = value

        if value_dt > max_dt:
            raise ValidationError('Value is after %s.' %
                                  safe_strftime(max_dt, dt_format))

        return value
Exemplo n.º 5
0
def after(min_dt, dt_format=HUMAN_DATE_FORMAT):
    if is_date(min_dt):
        min_dt = date_to_datetime(min_dt)

    def after_f(value):
        if is_date(value):
            value_dt = date_to_datetime(value)
        else:
            value_dt = value

        if value_dt < min_dt:
            raise ValidationError('Value is before %s.' % safe_strftime(min_dt, dt_format))

        return value

    return after_f
Exemplo n.º 6
0
def after(min_dt, dt_format=HUMAN_DATE_FORMAT):
    if is_date(min_dt):
        min_dt = date_to_datetime(min_dt)

    def after_f(value):
        if is_date(value):
            value_dt = date_to_datetime(value)
        else:
            value_dt = value

        if value_dt < min_dt:
            raise ValidationError('Value is before %s.' %
                                  safe_strftime(min_dt, dt_format))

        return value

    return after_f