def _resolve_time(t):
"""
Resolves the time string into datetime.time. This method
is needed because Caltrain arrival/departure time hours
can exceed 23 (e.g. 24, 25), to signify trains that arrive
after 12 AM. The 'day' variable is incremented from 0 in
these situations, and the time resolved back to a valid
datetime.time (e.g. 24:30:00 becomes days=1, 00:30:00).
:param t: the time to resolve
:type t: str or unicode
:returns: tuple of days and datetime.time
"""
hour, minute, second = [int(x) for x in t.split(":")]
day, hour = divmod(hour, 24)
r = _BASE_DATE + timedelta(hours=hour,
minutes=minute,
seconds=second)
return day, r.time()
评论列表
文章目录