convert comment time to UTC
This commit is contained in:
parent
9d6da1e7bb
commit
97d6ad447b
2 changed files with 13 additions and 3 deletions
|
|
@ -18,10 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .index import DLFPPage
|
|
||||||
from weboob.tools.parser import tostring
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from weboob.tools.parser import tostring
|
||||||
|
from weboob.tools.misc import local2utc
|
||||||
|
|
||||||
from weboob.backends.dlfp.tools import url2id
|
from weboob.backends.dlfp.tools import url2id
|
||||||
|
from .index import DLFPPage
|
||||||
|
|
||||||
class Comment(object):
|
class Comment(object):
|
||||||
def __init__(self, div, reply_id):
|
def __init__(self, div, reply_id):
|
||||||
|
|
@ -49,7 +52,7 @@ class Comment(object):
|
||||||
self.comments.append(comment)
|
self.comments.append(comment)
|
||||||
|
|
||||||
def parse_date(self, date_s):
|
def parse_date(self, date_s):
|
||||||
return datetime.strptime(unicode(date_s.strip()), u'le %d/%m/%Y à %H:%M.')
|
return local2utc(datetime.strptime(unicode(date_s.strip()), u'le %d/%m/%Y à %H:%M.'))
|
||||||
|
|
||||||
def iter_all_comments(self):
|
def iter_all_comments(self):
|
||||||
for comment in self.comments:
|
for comment in self.comments:
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from dateutil import tz
|
||||||
|
|
||||||
def toUnicode(text):
|
def toUnicode(text):
|
||||||
r"""
|
r"""
|
||||||
>>> toUnicode('ascii')
|
>>> toUnicode('ascii')
|
||||||
|
|
@ -37,3 +39,8 @@ def toUnicode(text):
|
||||||
pass
|
pass
|
||||||
return unicode(text, "ISO-8859-1")
|
return unicode(text, "ISO-8859-1")
|
||||||
|
|
||||||
|
def local2utc(d):
|
||||||
|
d = d.replace(tzinfo=tz.tzlocal())
|
||||||
|
d = d.astimezone(tz.tzutc())
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue