summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-10-05 19:06:17 -0300
committerVictor Shyba <victor.shyba@gmail.com>2015-10-05 19:06:17 -0300
commitf33fd98fa4b60142174302d9186082bf04b9749f (patch)
treed90874187510d587a121491ab82aa5bb04f2a692 /service
parent5e35fee9bce64d7648d67a8c1a789d4c3dc74a4d (diff)
[bug] use utc for sorting while indexing
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/search/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/service/pixelated/adapter/search/__init__.py b/service/pixelated/adapter/search/__init__.py
index 51ef6cd7..56ab2255 100644
--- a/service/pixelated/adapter/search/__init__.py
+++ b/service/pixelated/adapter/search/__init__.py
@@ -19,6 +19,7 @@ from pixelated.support.encrypted_file_storage import EncryptedFileStorage
import os
import re
import dateutil.parser
+import time
from pixelated.adapter.model.status import Status
from pixelated.adapter.search.contacts import contacts_suggestions
from whoosh.index import FileIndex
@@ -126,7 +127,7 @@ class SearchEngine(object):
index_data = {
'sender': self._empty_string_to_none(header.get('from', '')),
'subject': self._empty_string_to_none(header.get('subject', '')),
- 'date': dateutil.parser.parse(header.get('date', '')).strftime('%s'),
+ 'date': self._format_utc_integer(header.get('date', '')),
'to': self._format_recipient(header, 'to'),
'cc': self._format_recipient(header, 'cc'),
'bcc': self._format_recipient(header, 'bcc'),
@@ -139,6 +140,10 @@ class SearchEngine(object):
writer.update_document(**index_data)
+ def _format_utc_integer(self, date):
+ timetuple = dateutil.parser.parse(date).utctimetuple()
+ return time.strftime('%s', timetuple)
+
def _format_recipient(self, headers, name):
list = headers.get(name, [''])
return u','.join(list) if list else u''