Display event timestamps in the current user’s time zone
This commit is contained in:
		| @@ -197,6 +197,18 @@ class Event(db.Model): | ||||
|  | ||||
|         return self.__as_tz(self.end_time) | ||||
|  | ||||
|     def start_time_for_user(self, user): | ||||
|         """The same timestamp as `start_time`, but in the time zone of `user` | ||||
|         """ | ||||
|  | ||||
|         return self.__as_tz(self.start_time, as_timezone=user.timezone) | ||||
|  | ||||
|     def end_time_for_user(self, user): | ||||
|         """The same timestamp as `end_time`, but in the time zone of `user` | ||||
|         """ | ||||
|  | ||||
|         return self.__as_tz(self.end_time, as_timezone=user.timezone) | ||||
|  | ||||
|     def __repr__(self): | ||||
|         return f'<Event {self.id} ({self.title}) of {self.user}>' | ||||
|  | ||||
|   | ||||
| @@ -119,8 +119,7 @@ | ||||
|                 <span class="day-num">{{ day.day }}</span> | ||||
|     {% for event in calendar.day_events(day, user=current_user) %} | ||||
|                 <div class="event"> | ||||
|                     {{ event.start_time_tz.strftime('%H:%M') }}–{{ event.end_time_tz.strftime('%H:%M') }} | ||||
|                     ({{ event.time_zone }}) | ||||
|                     {{ event.start_time_for_user(current_user).strftime('%H:%M') }}–{{ event.end_time_for_user(current_user).strftime('%H:%M') }} | ||||
|                     {{ event.title }} | ||||
|                 </div> | ||||
|     {% endfor %} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user