Skip to content

Commit d2d6e4a

Browse files
authored
datetime.utc not valid
When trying to work with this example I received the error: ```bash AttributeError: module 'datetime' has no attribute 'UTC' ``` Doing some research, it seems the new pattern is to pull UTC from timezone. Making the suggested edit as a PR
1 parent 1844a2f commit d2d6e4a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

examples/sqlalchemy/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
from datetime import timezone
23
import logging
34

45
import connexion
@@ -29,7 +30,7 @@ def put_pet(pet_id, pet):
2930
p.update(**pet)
3031
else:
3132
logging.info("Creating pet %s..", pet_id)
32-
pet["created"] = datetime.datetime.now(datetime.UTC)
33+
pet["created"] = datetime.datetime.now(timezone.UTC)
3334
db_session.add(orm.Pet(**pet))
3435
db_session.commit()
3536
return NoContent, (200 if p is not None else 201)

0 commit comments

Comments
 (0)