def display_date(start, end): """ Formates the date range given for display. """ timezone = settings().timezone() start = sedate.to_timezone(start, timezone) end = sedate.to_timezone(end, timezone) if end.microsecond != 999999: end -= timedelta(microseconds=1) if (start, end) == align_range_to_day(start, end): if start.date() == end.date(): return localize_date(start, long_format=False) else: return ' - '.join((localize_date(start, long_format=False), localize_date(end, long_format=False))) end += timedelta(microseconds=1) if start.date() == end.date(): return ' - '.join( (localize_date(start, long_format=True), localize_date(end, time_only=True))) else: return ' - '.join((localize_date(start, long_format=True), localize_date(end, long_format=True)))
def display_date(start, end): """ Formates the date range given for display. """ timezone = settings().timezone() start = sedate.to_timezone(start, timezone) end = sedate.to_timezone(end, timezone) if end.microsecond != 999999: end -= timedelta(microseconds=1) if (start, end) == align_range_to_day(start, end): if start.date() == end.date(): return localize_date(start, long_format=False) else: return ' - '.join(( localize_date(start, long_format=False), localize_date(end, long_format=False) )) end += timedelta(microseconds=1) if start.date() == end.date(): return ' - '.join(( localize_date(start, long_format=True), localize_date(end, time_only=True) )) else: return ' - '.join(( localize_date(start, long_format=True), localize_date(end, long_format=True) ))
def event_class(availability): """Returns the event class to be used depending on the availability.""" s = settings() available = s.get('available_threshold') partly = s.get('partly_available_threshold') if availability >= available: return 'event-available' elif partly <= availability and availability < available: return 'event-partly-available' else: return 'event-unavailable'