Skip to content

Commit

Permalink
view_local_schedule script
Browse files Browse the repository at this point in the history
  • Loading branch information
jrdbnntt committed Feb 8, 2017
1 parent 9956444 commit 28fbdcd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 0 additions & 2 deletions hackfsu_com/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@
os.path.join(BASE_DIR, 'webapp/build/static'),
]



IGNORABLE_404_URLS = [
re.compile(r'\.(php|cgi|pug|scss)$'),
re.compile(r'^/node_modules/'),
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ mandrill
django-extensions
terminaltables
python-dateutil
pytz
34 changes: 34 additions & 0 deletions scripts/view_local_schedule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Prints the schedule in the local time zone
"""

from api.models import ScheduleItem, Hackathon
from datetime import datetime
from terminaltables import AsciiTable
import pytz


EASTERN = pytz.timezone('US/Eastern')


def format_time(dt: datetime):
dt = dt.astimezone(tz=EASTERN)
return dt.strftime('%a %I:%M %p')


def run():
h = Hackathon.objects.current()
items = ScheduleItem.objects.filter(hackathon=h).order_by('start', 'end')

title = '{} Schedule in {}'.format(h.name, EASTERN.zone)
data = [('Start', 'End', 'Event Name')]

for item in items:
data.append((
format_time(item.start),
format_time(item.end) if item.end is not None else 'n/a',
item.name
))

table = AsciiTable(table_data=data, title=title)
print(table.table)

0 comments on commit 28fbdcd

Please sign in to comment.