From ab306a04236e919c09225fb70cb1f987e196b528 Mon Sep 17 00:00:00 2001 From: Keith Mitchell Date: Wed, 22 Aug 2012 12:27:03 -0700 Subject: [PATCH] Search: Squash misuse of datetime.strftime --- r2/r2/controllers/front.py | 4 ++-- r2/r2/lib/cloudsearch.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py index 306a8a95d..10ffb0e16 100755 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -686,8 +686,8 @@ class FrontController(RedditController): query = "|".join(query.split()) query = "title:'%s'" % query rel_range = timedelta(days=3) - start = (article._date - rel_range).strftime("%s") - end = (article._date + rel_range).strftime("%s") + start = int(time.mktime((article._date - rel_range).utctimetuple())) + end = int(time.mktime((article._date + rel_range).utctimetuple())) nsfw = "nsfw:0" if not (article.over_18 or article._nsfw.findall(article.title)) else "" query = "(and %s timestamp:%s..%s %s)" % (query, start, end, nsfw) q = SearchQuery(query, raw_sort="-text_relevance", diff --git a/r2/r2/lib/cloudsearch.py b/r2/r2/lib/cloudsearch.py index 3fc924adf..2bbe50b49 100644 --- a/r2/r2/lib/cloudsearch.py +++ b/r2/r2/lib/cloudsearch.py @@ -252,7 +252,7 @@ class LinkUploader(CloudSearchUploader): "subreddit": sr.name, "reddit": sr.name, "title": thing.title, - "timestamp": thing._date.strftime("%s"), + "timestamp": int(time.mktime(thing._date.utctimetuple())), "sr_id": thing.sr_id, "over18": 1 if nsfw else 0, "is_self": 1 if thing.is_self else 0,