)]}'
{"rally/utils/timeutils.py":[{"author":{"_account_id":9545,"name":"Andriy Kurilin","email":"andr.kurilin@gmail.com","username":"akurilin"},"change_message_id":"0aa12e62d5317c3e6049ce4fd85ff2019214d5b5","unresolved":true,"context_lines":[{"line_number":17,"context_line":"import datetime as dt"},{"line_number":18,"context_line":""},{"line_number":19,"context_line":""},{"line_number":20,"context_line":"def utcnow() -\u003e dt.datetime:"},{"line_number":21,"context_line":"    \"\"\"Get current UTC time, which is not a timezone-aware."},{"line_number":22,"context_line":""},{"line_number":23,"context_line":"    This is a handy utiility to replace datetime.datetime.utcnow, which has"}],"source_content_type":"text/x-python","patch_set":2,"id":"32166666_7468f12d","line":20,"updated":"2026-10-23 16:01:01.000000000","message":"`datetime.datetime.utcnow` was deprecated for a reason. We should not blindly copy the old behavior. What should be done instead is using TZ everywhere.\n\ndatabase layer should be extended with a custome type. something like:\n\n```python\n\nclass DateTime(sa.TypeDecorator):\n    \"\"\"TIMESTAMP type that attaches UTC timezone info when loading from DB.\"\"\"\n    impl \u003d sa.Datatime\n    cache_ok \u003d True\n    python_type \u003d dt.datetime\n\t\n    def process_bind_param(\n        self, value: dt.datetime | None, dialect: sa.Dialect,\n    ) -\u003e dt.datetime | None:\n        if value and value.tzinfo is not None:\n            return value.astimezone(dt.UTC).replace(tzinfo\u003dNone)\n        return value\n\n    def process_result_value(\n        self, value: dt.datetime | None, dialect: sa.Dialect,\n    ) -\u003e dt.datetime | None:\n        if value and value.tzinfo is None:\n            return value.replace(tzinfo\u003ddt.UTC)\n        return value\n```\n\nThis would make all timestams to be loaded as datetime objects with UTC zone and allow using `dt.datetime.now(dt.UTC)` everywhere","commit_id":"96ada689149ec99ea573eb9754452a6dd266acab"}]}
