def process_date(value, lookup_type): from djangae.db.backends.appengine.commands import ensure_datetime #FIXME move func to utils value = ensure_datetime(value) ret = datetime.datetime.fromtimestamp(0) POSSIBLE_LOOKUPS = ("year", "month", "day", "hour", "minute", "second") ret = ret.replace( value.year, value.month if lookup_type in POSSIBLE_LOOKUPS[1:] else ret.month, value.day if lookup_type in POSSIBLE_LOOKUPS[2:] else ret.day, value.hour if lookup_type in POSSIBLE_LOOKUPS[3:] else ret.hour, value.minute if lookup_type in POSSIBLE_LOOKUPS[4:] else ret.minute, value.second if lookup_type in POSSIBLE_LOOKUPS[5:] else ret.second, ) return ret
def process_date(value, lookup_type): from djangae.db.backends.appengine.commands import ensure_datetime #FIXME move func to utils value = ensure_datetime(value) ret = datetime.datetime.fromtimestamp(0) POSSIBLE_LOOKUPS = ("year", "month", "day", "hour", "minute", "second") ret = ret.replace( value.year, value.month if lookup_type in POSSIBLE_LOOKUPS[1:] else ret.month, value.day if lookup_type in POSSIBLE_LOOKUPS[2:] else ret.day, value.hour if lookup_type in POSSIBLE_LOOKUPS[3:] else ret.hour, value.minute if lookup_type in POSSIBLE_LOOKUPS[4:] else ret.minute, value.second if lookup_type in POSSIBLE_LOOKUPS[5:] else ret.second, ) return ret