-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from kshvmdn/merge-dates
Merge event data for campuses based on date
- Loading branch information
Showing
7 changed files
with
91 additions
and
69 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
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,25 @@ | ||
from datetime import datetime | ||
|
||
|
||
def get_current_month(): | ||
"""Return current month.""" | ||
now = datetime.now() | ||
return '%s-%s' % (now.year, now.month) | ||
|
||
|
||
def get_campus_id(d, campus): | ||
"""Return campus id, made up of date and specifier (one of SG, M, SC).""" | ||
d = datetime.strptime(d, '%Y-%m-%d') | ||
return '%s%s' % (str(d.day).zfill(2), campus) | ||
|
||
|
||
def is_date_in_month(d, m): | ||
"""Determine if the given date is in the given month.""" | ||
d, m = datetime.strptime(d, '%Y-%m-%d'), datetime.strptime(m, '%Y-%m') | ||
return d.month == m.month | ||
|
||
|
||
def convert_time(dt): | ||
"""Convert datetime from ISO 8601 format to seconds since midnight.""" | ||
dt = datetime.strptime(dt[:19], '%Y-%m-%dT%H:%M:%S') | ||
return dt.hour * 60 * 60 + dt.minute * 60 |
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
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