Handle naive vs utc aware datetime
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
This commit is contained in:
parent
e4358590c3
commit
a2af2162f9
@ -8,6 +8,7 @@ from pymongo import MongoClient
|
||||
from wtforms import StringField, IntegerField, SelectField, BooleanField, DateTimeField, validators
|
||||
from wtforms.validators import DataRequired
|
||||
|
||||
import pytz
|
||||
import const
|
||||
from common import spam, users_lookup, users, User
|
||||
from oidc import login_required, read_user
|
||||
@ -226,17 +227,23 @@ def view_doorboy_admin():
|
||||
|
||||
def datetime_handle(item):
|
||||
if not item:
|
||||
return datetime.min
|
||||
dt = datetime.min
|
||||
elif type(item) is str:
|
||||
try:
|
||||
return parse(item)
|
||||
dt = parse(item)
|
||||
except ParserError as e:
|
||||
print(e)
|
||||
return datetime.min
|
||||
dt = datetime.min
|
||||
elif type(item) is datetime:
|
||||
return item
|
||||
dt = item
|
||||
else:
|
||||
return datetime.min
|
||||
dt = datetime.min
|
||||
|
||||
try:
|
||||
dt = pytz.UTC.localize(dt)
|
||||
except ValueError:
|
||||
pass
|
||||
return dt
|
||||
|
||||
@page_doorboy.route("/m/doorboy/swipes")
|
||||
@login_required
|
||||
|
@ -7,6 +7,7 @@ Flask
|
||||
jinja2
|
||||
jpegtran-cffi
|
||||
markdown
|
||||
pytz
|
||||
requests
|
||||
safe
|
||||
sepa
|
||||
|
Loading…
Reference in New Issue
Block a user