|
@@ -3,6 +3,7 @@ from bson.objectid import ObjectId
|
|
|
import datetime
|
|
import datetime
|
|
|
import re
|
|
import re
|
|
|
import news
|
|
import news
|
|
|
|
|
+import pytz
|
|
|
|
|
|
|
|
class db():
|
|
class db():
|
|
|
DB="alexis"
|
|
DB="alexis"
|
|
@@ -11,6 +12,22 @@ class db():
|
|
|
self.c_sources=self.client[self.DB]["sources"]
|
|
self.c_sources=self.client[self.DB]["sources"]
|
|
|
self.c_articles=self.client[self.DB]["articles"]
|
|
self.c_articles=self.client[self.DB]["articles"]
|
|
|
|
|
|
|
|
|
|
+ def change_timezone(self,el):
|
|
|
|
|
+ gmt = pytz.timezone("America/Buenos_Aires")
|
|
|
|
|
+ est = pytz.timezone('US/Eastern')
|
|
|
|
|
+ #est = pytz.timezone('America/Boston')
|
|
|
|
|
+ fmt = '%Y-%m-%d %H:%M:%S %Z%z'
|
|
|
|
|
+
|
|
|
|
|
+ #print(el["scrap_date"])
|
|
|
|
|
+ el["scrap_date"]=gmt.localize(el["scrap_date"])
|
|
|
|
|
+ #print(el["scrap_date"])
|
|
|
|
|
+ el["scrap_date"]=el["scrap_date"].astimezone(est)
|
|
|
|
|
+ #print(el["scrap_date"])
|
|
|
|
|
+ el["scrap_date"]=el["scrap_date"].strftime(fmt)
|
|
|
|
|
+ #print(el["scrap_date"])
|
|
|
|
|
+ #el["scrap_date"]=est.astimezone(el["scrap_date" ])
|
|
|
|
|
+ #est.localize(el["scrap_date"])
|
|
|
|
|
+ return el
|
|
|
def jsonable(self, el):
|
|
def jsonable(self, el):
|
|
|
if el is None or "_id" not in el:
|
|
if el is None or "_id" not in el:
|
|
|
return el
|
|
return el
|
|
@@ -52,6 +69,7 @@ class db():
|
|
|
db_filter["kw"]={"$all": filter["keyword"]}
|
|
db_filter["kw"]={"$all": filter["keyword"]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
#db_filter["kw.0"]={"$exists":False}
|
|
#db_filter["kw.0"]={"$exists":False}
|
|
|
pageNumber=0
|
|
pageNumber=0
|
|
|
if "page" in filter:
|
|
if "page" in filter:
|
|
@@ -65,7 +83,7 @@ class db():
|
|
|
else:
|
|
else:
|
|
|
q = []
|
|
q = []
|
|
|
count = 0
|
|
count = 0
|
|
|
- return { 'articles': [ self.jsonable(p) for p in q ],
|
|
|
|
|
|
|
+ return { 'articles': [ self.jsonable(self.change_timezone(p)) for p in q ],
|
|
|
'count' : count }
|
|
'count' : count }
|
|
|
|
|
|
|
|
def article(self, id):
|
|
def article(self, id):
|