split categories, sitemap and other crap out of news.py

This commit is contained in:
Jason Schwarzenberger
2020-11-16 15:30:33 +13:00
parent b80c1a5cb5
commit 6a91b9402f
8 changed files with 384 additions and 310 deletions
+18
View File
@@ -0,0 +1,18 @@
import pytz
import dateutil.parser
TZINFOS = {
'NZDT': pytz.timezone('Pacific/Auckland'),
'NZST': pytz.timezone('Pacific/Auckland')
}
def unix(date_str, tz=None, tzinfos=TZINFOS):
try:
dt = dateutil.parser.parse(date_str, tzinfos=tzinfos)
if tz:
dt = pytz.timezone(tz).localize(dt)
return int(dt.timestamp())
except:
pass
return 0