Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change decimal hours to seconds since midnight #65

Merged
merged 1 commit into from
Apr 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uoftscrapers/scrapers/courses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def parse_course_html(course_id, html):

for i in range(len(hours)):
x = hours[i].split(':')
hours[i] = int(x[0]) + (int(x[1]) / 60)
hours[i] = (60 * 60 * int(x[0])) + (int(x[1]) * 60)

time_data.append(OrderedDict([
("day", day),
Expand Down
6 changes: 3 additions & 3 deletions uoftscrapers/scrapers/food/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def get_hours(food_id):
"""Parse and return the restaurant's opening and closing times."""

def conv_time(t):
"""Convert time of form "HH:MM p.d." to decimal (p.d. is one
of a.m./p.m.)"""
"""Convert time of form "HH:MM p.d." to seconds since midnight (p.d.
is one of a.m./p.m.)"""

time, period = t[:-4].strip(), t[-4:].strip()

Expand All @@ -94,7 +94,7 @@ def conv_time(t):
h = int(time)

h += 12 if period == 'p.m.' else 0
return h + (m / 60)
return (60 * 60 * h) + (60 * m)

headers = {
'Referer': Food.host
Expand Down