diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-06-18 18:43:30 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-06-18 18:43:30 (GMT) |
commit | ed2890927d79792e9222f61c19969352b614da8f (patch) | |
tree | 0ff7d05900a180d917ff414640d05ff056a87fda /program/templatetags | |
parent | 2c8661d1e17cdd26d5f347d8a5fb332b5d267fe6 (diff) |
fixed week view.
Diffstat (limited to 'program/templatetags')
-rw-r--r-- | program/templatetags/timeslots.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/program/templatetags/timeslots.py b/program/templatetags/timeslots.py new file mode 100644 index 0000000..9b83a80 --- /dev/null +++ b/program/templatetags/timeslots.py @@ -0,0 +1,22 @@ +from django import template + +register = template.Library() + +from datetime import datetime, time, timedelta + +@register.simple_tag +def duration(start, end): + return 'style="height: %dpx"' % ((end-start).seconds/60) + +@register.simple_tag +def duration_until(end): + start = datetime.combine(end.date(), time(6,0)) + return 'style="height: %dpx"' % ((end-start).seconds/60) + +@register.simple_tag +def duration_since(start): + if start.time()<time(0,0): + end = datetime.combine(start.date()+timedelta(days=1), time(6,0)) + else: + end = datetime.combine(start.date(), time(6,0)) + return 'style="height: %dpx"' % ((end-start).seconds/60)
\ No newline at end of file |