schlosser / eventum

An event-driven CMS that syncs with Google Apps
21 stars 15 forks source link

Smart titles for dates and parts of the events #19

Open schlosser opened 10 years ago

schlosser commented 10 years ago

"Today", "Tomorrow", "This week", "Last week", "Next Week"

pkathail commented 9 years ago

in Event.py, human_readable_datetime(self) and human_readable_date(self), compare event date to now and replace with Today, Tomorrow, Last week, or Next week if applicable. time_diff = self.start_datetime() - now if self.start_date().month == now.month and self.start_datetime().day == now.day: (title needs to be changed to today) output += "Today, " + self.start_date.strftime("%B %d ") \ .replace(" 0", " ").replace("/0", "/") if self.start_date().month == now.month and self.start_datetime().day == now.day +1: (title needs to be changed to tomorrow) output += "Tomorrow, " + self.start_date.strftime("%B %d ") \ .replace(" 0", " ").replace("/0", "/") if self.start_date().isocalendar()[1] == now.isocalendar()[1]: (title needs to be changed to this week) output += "This week, " + self.start_date.strftime("%A, %B %d ") \ .replace(" 0", " ").replace("/0", "/") if self.start_date().isocalendar()[1] == now.isocalendar()[1] +1: (title needs to be changed to next week) output += "Next week, " + self.start_date.strftime("%A, %B %d ") \ .replace(" 0", " ").replace("/0", "/")