| defparse_datetime(val): |
| ifisinstance(val, datetime): |
| returnval.astimezone(timezone.utc) |
| ifisinstance(val, (int, float)): |
| returndatetime.fromtimestamp(val, timezone.utc) |
the yaml importer creates aware datetime objects with the timezone set to utc. sqlalchemy doesn't seem to enjoy these:
>>>importcms.db>>>fromdatetimeimportdatetime, timezone>>>session=cms.db.Session()
>>>contest=cms.db.Contest.get_from_id(1, session)
>>>contest.start=datetime(2025, 9, 28, tzinfo=timezone.utc)
>>>contest.startdatetime.datetime(2025, 9, 28, 0, 0, tzinfo=datetime.timezone.utc)
>>>session.commit()
>>>contest.startdatetime.datetime(2025, 9, 28, 3, 0)
short term fix: we need to convert these aware datetimes to naive before passing them to sqlalchemy. longer term fix: we should probably be using aware datetimes instead... and possibly upgrading our sqlalchemy (it already throws warnings about deprecated datetime methods)
cms/cmscontrib/loaders/italy_yaml.py
Lines 127 to 131 in fcb70ee
the yaml importer creates aware datetime objects with the timezone set to utc. sqlalchemy doesn't seem to enjoy these:
short term fix: we need to convert these aware datetimes to naive before passing them to sqlalchemy. longer term fix: we should probably be using aware datetimes instead... and possibly upgrading our sqlalchemy (it already throws warnings about deprecated datetime methods)