Repository: fossasia/open-event-server

Issue:
Event Ticket time start on local PC time instead of Time of Event location
After the user entered the ticket, the ticket time starting the sales is automatically chosen - as the current time.

The time displayed is the current ticket time of the time zone. If the timezone of the user/PC is different to the timezone of the event, the ticket time still shows the PC timezone.

Expected behavior: Show the timezone of the event and make all ticket sales according to the event timezone.

![screenshot from 2016-12-31 22-19-44](https://cloud.githubusercontent.com/assets/1583873/21579287/9288d848-cfa7-11e6-9d1f-95c161a0723d.png)



Discussion:
I'd like to try and work on this.

Resolving patch:
diff --git a/app/__init__.py b/app/__init__.py
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -395,6 +395,24 @@ def localize_dt(dt, tzname):
     return localized_dt.isoformat()
 
 
+@app.template_filter('localize_dt_obj')
+def localize_dt_obj(dt, tzname):
+    """Accepts a Datetime object and a Timezone name.
+    Returns Timezone aware Datetime Object.
+    """
+    localized_dt = timezone(tzname).localize(dt)
+    return localized_dt
+
+
+@app.template_filter('as_timezone')
+def as_timezone(dt, tzname):
+    """Accepts a Time aware Datetime object and a Timezone name.
+        Returns Converted Timezone aware Datetime Object.
+        """
+    converted_dt = dt.astimezone(timezone(tzname))
+    return converted_dt
+
+
 @app.context_processor
 def fb_app_id():
     fb_app_id = get_settings()['fb_client_id']
diff --git a/app/views/public/event_detail.py b/app/views/public/event_detail.py
--- a/app/views/public/event_detail.py
+++ b/app/views/public/event_detail.py
@@ -1,5 +1,6 @@
 import json
 from datetime import datetime
+import pytz
 
 from flask import Blueprint
 from flask import make_response
@@ -16,6 +17,7 @@
 from app.helpers.exporters.xcal import XCalExporter
 from app.helpers.helpers import get_count
 from app.models.call_for_papers import CallForPaper
+from app.helpers.wizard.helpers import get_current_timezone
 
 
 def get_published_event_or_abort(identifier):
@@ -65,6 +67,8 @@ def display_event_detail_home(identifier):
             if speaker not in speakers:
                 speakers.append(speaker)
 
+    '''Timezone aware current datetime object according to event timezone'''
+    timenow_event_tz = datetime.now(pytz.timezone(event.timezone))
     module = DataGetter.get_module()
     tickets = DataGetter.get_sales_open_tickets(event.id, True)
     return render_template('gentelella/guest/event/details.html',
@@ -77,6 +81,8 @@ def display_event_detail_home(identifier):
                            licence_details=licence_details,
                            speakers=speakers,
                            module=module,
+                           timenow_event_tz=timenow_event_tz,
+                           current_timezone=get_current_timezone(),
                            tickets=tickets if tickets else [])
 
 
@@ -334,6 +340,7 @@ def display_event_tickets(identifier):
     module = DataGetter.get_module()
     tickets = DataGetter.get_sales_open_tickets(event.id, True)
     accepted_sessions_count = get_count(DataGetter.get_sessions(event.id))
+    timenow_event_tz = datetime.now(pytz.timezone(event.timezone))
     return render_template('gentelella/guest/event/details.html',
                            event=event,
                            placeholder_images=placeholder_images,
@@ -341,6 +348,8 @@ def display_event_tickets(identifier):
                            accepted_sessions_count=accepted_sessions_count,
                            licence_details=licence_details,
                            module=module,
+                           timenow_event_tz=timenow_event_tz,
+                           current_timezone=get_current_timezone(),
                            tickets=tickets if tickets else [])
 
 


Test patch: