diff options
author | Markus Holtermann <info@markusholtermann.eu> | 2013-01-25 00:38:34 +0100 |
---|---|---|
committer | Markus Holtermann <info@markusholtermann.eu> | 2013-01-25 00:38:34 +0100 |
commit | 7f94efd504837375411eea3b6dfb0cd9659f8014 (patch) | |
tree | 9b04998f8fb0799bbddad757d7d18a2ccc744072 /bvggrabber | |
parent | f1336d76dd4a65cba979afdabbafeb18c2a14e03 (diff) | |
download | bvg-grabber-7f94efd504837375411eea3b6dfb0cd9659f8014.tar.gz bvg-grabber-7f94efd504837375411eea3b6dfb0cd9659f8014.tar.bz2 bvg-grabber-7f94efd504837375411eea3b6dfb0cd9659f8014.zip |
Fix day-change bugs in bvggrabber.api.Departure
Diffstat (limited to 'bvggrabber')
-rw-r--r-- | bvggrabber/api/__init__.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/bvggrabber/api/__init__.py b/bvggrabber/api/__init__.py index daaeca0..1e31359 100644 --- a/bvggrabber/api/__init__.py +++ b/bvggrabber/api/__init__.py @@ -21,14 +21,14 @@ class Departure(): def __init__(self, start, end, when, line): self.start = start self.end = end + self.now = datetime.now() if isinstance(when, (int, float)): - # We assume to get a UNIX timestamp + # We assume to get a UNIX / POSIX timestamp self.when = datetime.fromtimestamp(when) elif isinstance(when, str): self.when = parse(when) - now = datetime.now() - if (self.when - now).total_seconds() < 0: - self.when = self.when.replace(day=self.when.day + 1) + #if (self.when - self.now).total_seconds() < -60: + # self.when = self.when + timedelta(days=1) elif isinstance(when, datetime): self.when = when else: @@ -36,11 +36,13 @@ class Departure(): self.line = line def __str__(self): - return "Start: %s, End: %s, when: %s, line: %s" % ( - self.start, self.end, fullformat(self.when), self.line) + return "Start: %s, End: %s, when: %s, now: %s, line: %s" % ( + self.start, self.end, fullformat(self.when), fullformat(self.now), + self.line) + @property def remaining(self): - return self.when - datetime.now() + return self.when - self.now def to_json(self): pass |