From 4a8cad8a003e791c1904369ab3a090025c177a14 Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Wed, 6 May 2015 19:46:51 +0200 Subject: [PATCH] Fix SQLite date sorting --- tools/pecosys2stacosys.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/pecosys2stacosys.py b/tools/pecosys2stacosys.py index 600ab6d..f68873b 100644 --- a/tools/pecosys2stacosys.py +++ b/tools/pecosys2stacosys.py @@ -5,6 +5,7 @@ import sys import os import re import logging +import datetime from clize import clize, run # add necessary directories to PATH @@ -34,7 +35,6 @@ logger.addHandler(ch) # regex regex = re.compile(r"(\w+):\s*(.*)") - def convert_comment(db, site, filename): logger.info('convert %s' % filename) d = {} @@ -69,8 +69,9 @@ def convert_comment(db, site, filename): # else: # comment.url = d['article'] if 'date' in d: - comment.created = d['date'] - comment.published = d['date'] + pub = datetime.datetime.strptime(d['date'], '%Y-%m-%d %H:%M:%S') + comment.created = pub + comment.published = pub comment.save()