diff --git a/smash/web/utils.py b/smash/web/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..85341925a55903081ea73c114c887f38f6078b89 --- /dev/null +++ b/smash/web/utils.py @@ -0,0 +1,23 @@ +# coding=utf-8 +from django.utils import timezone +import datetime, time + +def timeit(method): + def timed(*args, **kw): + ts = time.time() + result = method(*args, **kw) + te = time.time() + if 'log_time' in kw: + name = kw.get('log_name', method.__name__.upper()) + kw['log_time'][name] = int((te - ts) * 1000) + else: + print '%r %2.2f ms' % \ + (method.__name__, (te - ts) * 1000) + return result + return timed + +def get_today_midnight_date(): + today = timezone.now() + today_midnight = datetime.datetime(today.year, today.month, today.day, tzinfo=today.tzinfo) + return today_midnight +