Skip to content

Commit

Permalink
Various style edits
Browse files Browse the repository at this point in the history
  • Loading branch information
dexw25 committed Feb 16, 2018
1 parent 5e1664e commit 5955450
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions semesters.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def semester_date(semester):
year = int(semester)
semester = semester - year
month = (1 if round(semester, 1) == 0.1 else FALL_START_MONTH)

return datetime(year, month, 1)

def semester_pretty(semester):
Expand All @@ -74,14 +73,18 @@ def semester_pretty(semester):
return semester_str + ' ' + `year`

def validate_semester(semester):
try: semester = float(semester)
# Don't accept anything that does not cast to a float
except ValueError: return None
try:
semester = float(semester)
# Don't accept anything that does not cast to a float.
except ValueError:
return None

# Reject semesters that are not in this milennia
# Reject semesters that are not in this milennium.
if semester > 3000 or semester < 2000:
return None

# Reject semesters that are not Fall or Spring
elif round(semester - int(semester), 1) not in [.1, .2]:
elif round(semester - int(semester), 1) not in [0.1, 0.2]:
return None
else: return semester
else:
return semester

0 comments on commit 5955450

Please sign in to comment.