summaryrefslogtreecommitdiff
path: root/bvggrabber
diff options
context:
space:
mode:
authorChristian Struck <christian@struck.se>2013-01-31 15:40:58 +0100
committerChristian Struck <christian@struck.se>2013-01-31 15:40:58 +0100
commit6a71307e5affd7653db04d9943c77cccf30c3886 (patch)
tree88775b2cbe07dc79e4f648444aebdf23eb400152 /bvggrabber
parentc10021e4d0e7f3cc54ecc796a4b979d92d666eb5 (diff)
downloadbvg-grabber-6a71307e5affd7653db04d9943c77cccf30c3886.tar.gz
bvg-grabber-6a71307e5affd7653db04d9943c77cccf30c3886.tar.bz2
bvg-grabber-6a71307e5affd7653db04d9943c77cccf30c3886.zip
added function dateformat and renamed function hourformat to timeformat and removed wrong enc in actualdeparture
Diffstat (limited to 'bvggrabber')
-rw-r--r--bvggrabber/api/__init__.py8
-rw-r--r--bvggrabber/api/actualdeparture.py2
-rw-r--r--bvggrabber/api/scheduleddeparture.py4
-rw-r--r--bvggrabber/utils/format.py13
4 files changed, 19 insertions, 8 deletions
diff --git a/bvggrabber/api/__init__.py b/bvggrabber/api/__init__.py
index ba68450..b13f756 100644
--- a/bvggrabber/api/__init__.py
+++ b/bvggrabber/api/__init__.py
@@ -65,9 +65,9 @@ class Departure(object):
'end': self.end,
'line': self.line,
'now_full': fullformat(self.now),
- 'now_hour': hourformat(self.now),
+ 'now_hour': timeformat(self.now),
'when_full': fullformat(self.when),
- 'when_hour': hourformat(self.when),
+ 'when_hour': timeformat(self.when),
'remaining': round(self.remaining)})
def __eq__(self, other):
@@ -92,5 +92,5 @@ class Departure(object):
def __str__(self):
return "Start: %s, End: %s, when: %s, now: %s, line: %s" % (
- self.start, self.end, hourformat(self.when),
- hourformat(self.now), self.line)
+ self.start, self.end, timeformat(self.when),
+ timeformat(self.now), self.line)
diff --git a/bvggrabber/api/actualdeparture.py b/bvggrabber/api/actualdeparture.py
index c55a47e..93213ef 100644
--- a/bvggrabber/api/actualdeparture.py
+++ b/bvggrabber/api/actualdeparture.py
@@ -47,7 +47,7 @@ class ActualDepartureQueryApi(QueryApi):
for row in rows:
td = row.find_all('td')
if td:
- dep = Departure(start=self.station_enc,
+ dep = Departure(start=self.station,
end=td[2].text.strip(),
when=td[0].text.strip(),
line=td[1].text.strip())
diff --git a/bvggrabber/api/scheduleddeparture.py b/bvggrabber/api/scheduleddeparture.py
index 5387057..61c4b57 100644
--- a/bvggrabber/api/scheduleddeparture.py
+++ b/bvggrabber/api/scheduleddeparture.py
@@ -43,8 +43,8 @@ class ScheduledDepartureQueryApi(QueryApi):
def call(self):
params = {'input': self.station_enc,
- 'time': hourformat(datetime.datetime.now()),
- 'date': datetime.datetime.now().strftime('%d.%m.%Y'),
+ 'time': timeformat(datetime.datetime.now()),
+ 'date': dateformat(datetime.datetime.now()),
'productsFilter': self.vehicles,
'maxJourneys': self.limit,
'start': 'yes'}
diff --git a/bvggrabber/utils/format.py b/bvggrabber/utils/format.py
index 603124b..d39868a 100644
--- a/bvggrabber/utils/format.py
+++ b/bvggrabber/utils/format.py
@@ -12,7 +12,7 @@ def fullformat(dt):
return dt.strftime('%Y-%m-%d %H:%M:%S')
-def hourformat(dt):
+def timeformat(dt):
"""Formats a datetime object as HH:MM
:param datetime dt: The datetime.datetime object to format
@@ -23,6 +23,17 @@ def hourformat(dt):
return dt.strftime('%H:%M')
+def dateformat(dt):
+ """Formats a datetime object as dd.mm.yyyy
+
+ :param datetime dt: The datetime.datetime object to format
+ :return: A formattet string
+ :rtype: str
+
+ """
+ return dt.strftime('%d.%m.%Y')
+
+
def int2bin(i, length=8):
"""Returns the bit representation of the given integer with a minimum
length of ``length``. E.g. ``int2bin(109, 7) == '1101101'`` and