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 import StringField, IntegerField, SelectField, BooleanField, DateTimeField, validators
|
||||||
from wtforms.validators import DataRequired
|
from wtforms.validators import DataRequired
|
||||||
|
|
||||||
|
import pytz
|
||||||
import const
|
import const
|
||||||
from common import spam, users_lookup, users, User
|
from common import spam, users_lookup, users, User
|
||||||
from oidc import login_required, read_user
|
from oidc import login_required, read_user
|
||||||
@ -226,17 +227,23 @@ def view_doorboy_admin():
|
|||||||
|
|
||||||
def datetime_handle(item):
|
def datetime_handle(item):
|
||||||
if not item:
|
if not item:
|
||||||
return datetime.min
|
dt = datetime.min
|
||||||
elif type(item) is str:
|
elif type(item) is str:
|
||||||
try:
|
try:
|
||||||
return parse(item)
|
dt = parse(item)
|
||||||
except ParserError as e:
|
except ParserError as e:
|
||||||
print(e)
|
print(e)
|
||||||
return datetime.min
|
dt = datetime.min
|
||||||
elif type(item) is datetime:
|
elif type(item) is datetime:
|
||||||
return item
|
dt = item
|
||||||
else:
|
else:
|
||||||
return datetime.min
|
dt = datetime.min
|
||||||
|
|
||||||
|
try:
|
||||||
|
dt = pytz.UTC.localize(dt)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
return dt
|
||||||
|
|
||||||
@page_doorboy.route("/m/doorboy/swipes")
|
@page_doorboy.route("/m/doorboy/swipes")
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -7,6 +7,7 @@ Flask
|
|||||||
jinja2
|
jinja2
|
||||||
jpegtran-cffi
|
jpegtran-cffi
|
||||||
markdown
|
markdown
|
||||||
|
pytz
|
||||||
requests
|
requests
|
||||||
safe
|
safe
|
||||||
sepa
|
sepa
|
||||||
|
Loading…
Reference in New Issue
Block a user