forked from tanner/qotnews
use localize
This commit is contained in:
parent
095f0d549a
commit
c391c50ab1
|
@ -29,14 +29,14 @@ def unix(date_str, tz=None):
|
||||||
try:
|
try:
|
||||||
dt = datetime.strptime(date_str, f)
|
dt = datetime.strptime(date_str, f)
|
||||||
if tz:
|
if tz:
|
||||||
dt = dt.replace(tzinfo=pytz.timezone(tz))
|
dt = pytz.timezone(tz).localize(dt)
|
||||||
return int(dt.timestamp())
|
return int(dt.timestamp())
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
dt = datetime.strptime(date_tzfix, f)
|
dt = datetime.strptime(date_tzfix, f)
|
||||||
if tz:
|
if tz:
|
||||||
dt = dt.replace(tzinfo=pytz.timezone(tz))
|
dt = pytz.timezone(tz).localize(dt)
|
||||||
return int(dt.timestamp())
|
return int(dt.timestamp())
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -223,4 +223,4 @@ if __name__ == '__main__':
|
||||||
print(posts[:1])
|
print(posts[:1])
|
||||||
print(site.story(posts[0]))
|
print(site.story(posts[0]))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user