from django.template import Library from datetime import datetime, timedelta @register.filter def is_day_of(value,arg): return (arg and value) and arg.day == int(value) @register.filter def is_month_of(value,arg): return (arg and value) and arg.month == int(value) @register.filter def is_year_of(value,arg): return (arg and value) and arg.year == int(value) @register.filter def is_hour_of(value,arg): return (arg and value) and arg.hour == int(value) @register.filter def is_minute_of(value,arg): return (arg and value) and arg.minute == int(value) @register.filter def dec_year(value,arg): delta = type(arg) != types.IntType and int(arg) or arg return value - timedelta(365 * delta) @register.filter def dec_month(value,arg): delta = type(arg) != types.IntType and int(arg) or arg return value - timedelta(30 * delta) @register.filter def inc_year(value,arg): delta = type(arg) != types.IntType and int(arg) or arg return value + timedelta(365 * delta) @register.filter def inc_month(value,arg): delta = type(arg) != types.IntType and int(arg) or arg return value + timedelta(30 * delta)