2 # vi: set softtabstop=4 shiftwidth=4 tabstop=8 expandtab:
7 """Defines a trip time and constraint (e.g. MUST_LEAVE_AFTER)."""
8 def __init__(self
, unixtime
, constraint
):
9 self
.unixtime
= unixtime
10 self
.constraint
= constraint
12 def toPlannerParams(self
):
13 """Let's hope your timezone is Eastern. Otherwise this isn't going
14 to return the right times. I don't see a way to locally override
15 the timezone in Python without defining my own tzinfo subclass.
16 I do not feel like installing pytz."""
17 loc
= time
.localtime(self
.unixtime
)
18 ymd
= time
.strftime("%Y-%m-%d", loc
)
19 params
= (("dateSelect", ymd
), ("day", ymd
),
21 ("visibleDay", time
.strftime("%B ", loc
) + str(loc
.tm_mday
)),
22 ("requestCode", self
.constraint
),
23 ("time", time
.strftime("%I:%M", loc
)),
24 ("timePeriod", time
.strftime("%p", loc
).lower()),
25 ("ok.x", 29), ("ok.y", 21))
28 APPROX_ARRIVAL_TIME
= 0
29 MUST_ARRIVE_BEFORE
= 1
30 APPROX_DEPARTURE_TIME
= 2