Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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