diff --git a/parse.py b/parse.py index c11bd8b..a67df1b 100755 --- a/parse.py +++ b/parse.py @@ -4,6 +4,7 @@ import sys import argparse import datetime import urllib.request +import dateutil.parser from icalendar import Calendar from html.parser import HTMLParser from icalendar import vDatetime, Calendar, Event as CalEvent @@ -119,9 +120,6 @@ class TableHTMLParser(HTMLParser): if self.iscell(): self.cell += data -# TODO Use HTTP header date -UPDATE_TIME = datetime.datetime.now() - # TODO Do something that really is OOP or do not... class Event: @@ -197,11 +195,12 @@ class Event: e.add('dtstart', self.startTime) e.add('dtend', self.endTime) e.add('location', self.location) - e.add('last-modified', UPDATE_TIME) - e.add('dtstamp', UPDATE_TIME) + e.add('last-modified', updateTime) + e.add('dtstamp', updateTime) return e with urllib.request.urlopen(url) as handle: + updateTime = dateutil.parser.parse(handle.headers['Last-Modified']) htmlStr = handle.read().decode('iso-8859-15') # Read HTML tables -- libgit2 0.21.2