diff options
author | Markus Holtermann <info@markusholtermann.eu> | 2013-01-31 19:50:34 +0100 |
---|---|---|
committer | Christian Struck <christian@struck.se> | 2013-01-31 19:55:54 +0100 |
commit | 9caefee9893048f169bc451cd9c454e0af668deb (patch) | |
tree | c3cb5c47fe3580f293467d822159b246cc823e97 /bvggrabber | |
parent | 59929df267e4480a9f7c123c4e22c28b49e78758 (diff) | |
download | bvg-grabber-9caefee9893048f169bc451cd9c454e0af668deb.tar.gz bvg-grabber-9caefee9893048f169bc451cd9c454e0af668deb.tar.bz2 bvg-grabber-9caefee9893048f169bc451cd9c454e0af668deb.zip |
Fixup travis#25
Signed-off-by: Christian Struck <christian@struck.se>
Diffstat (limited to 'bvggrabber')
-rw-r--r-- | bvggrabber/api/__init__.py | 2 | ||||
-rw-r--r-- | bvggrabber/api/scheduleddeparture.py | 4 | ||||
-rw-r--r-- | bvggrabber/utils/format.py | 38 |
3 files changed, 22 insertions, 22 deletions
diff --git a/bvggrabber/api/__init__.py b/bvggrabber/api/__init__.py index b13f756..36c913b 100644 --- a/bvggrabber/api/__init__.py +++ b/bvggrabber/api/__init__.py @@ -8,7 +8,7 @@ from math import floor from dateutil.parser import parse -from bvggrabber.utils.format import hourformat, fullformat +from bvggrabber.utils.format import fullformat, timeformat def compute_remaining(start, end): diff --git a/bvggrabber/api/scheduleddeparture.py b/bvggrabber/api/scheduleddeparture.py index 61c4b57..ba8a453 100644 --- a/bvggrabber/api/scheduleddeparture.py +++ b/bvggrabber/api/scheduleddeparture.py @@ -5,9 +5,9 @@ import datetime from bs4 import BeautifulSoup -from bvggrabber.api import QueryApi, Departure, hourformat +from bvggrabber.api import QueryApi, Departure -from bvggrabber.utils.format import int2bin +from bvggrabber.utils.format import dateformat, int2bin, timeformat SCHEDULED_API_ENDPOINT = 'http://mobil.bvg.de/Fahrinfo/bin/stboard.bin/dox' diff --git a/bvggrabber/utils/format.py b/bvggrabber/utils/format.py index d39868a..5f20e42 100644 --- a/bvggrabber/utils/format.py +++ b/bvggrabber/utils/format.py @@ -1,37 +1,26 @@ #-*- coding: utf-8 -*- -def fullformat(dt): - """Formats a datetime object as YYYY-MM-DD HH:MM:SS - - :param datetime dt: The datetime.datetime object to format - :return: A formattet string - :rtype: str - - """ - return dt.strftime('%Y-%m-%d %H:%M:%S') - - -def timeformat(dt): - """Formats a datetime object as HH:MM +def dateformat(dt): + """Formats a datetime object as dd.mm.yyyy :param datetime dt: The datetime.datetime object to format - :return: A formattet string + :return: A formatted string :rtype: str """ - return dt.strftime('%H:%M') + return dt.strftime('%d.%m.%Y') -def dateformat(dt): - """Formats a datetime object as dd.mm.yyyy +def fullformat(dt): + """Formats a datetime object as YYYY-MM-DD HH:MM:SS :param datetime dt: The datetime.datetime object to format - :return: A formattet string + :return: A formatted string :rtype: str """ - return dt.strftime('%d.%m.%Y') + return dt.strftime('%Y-%m-%d %H:%M:%S') def int2bin(i, length=8): @@ -49,3 +38,14 @@ def int2bin(i, length=8): if not isinstance(length, int): raise ValueError("expected int for length") return ('{:0>' + str(length) + 'b}').format(i) + + +def timeformat(dt): + """Formats a datetime object as HH:MM + + :param datetime dt: The datetime.datetime object to format + :return: A formatted string + :rtype: str + + """ + return dt.strftime('%H:%M') |