forked from HackFSU/hackfsu-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ mandrill | |
django-extensions | ||
terminaltables | ||
python-dateutil | ||
pytz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |