[loop-generated] [bug] Deprecated datetime.utcnow() usage across codebase #633

Closed
opened 2026-03-20 20:46:24 +00:00 by Timmy · 2 comments
Owner

Description

datetime.utcnow() is deprecated since Python 3.12 (PEP 587). It returns naive datetime objects that can cause subtle timezone bugs.

Affected files

  • src/timmy/mcp_tools.py (line 199)
  • src/dashboard/models/calm.py (lines 43-44, 62)
  • src/dashboard/routes/tasks.py (lines 222, 290, 319, 361)
  • src/dashboard/routes/work_orders.py (lines 147, 214)

Fix

Replace all datetime.utcnow() with datetime.now(timezone.utc):

from datetime import datetime, timezone
# Before:
datetime.utcnow()
# After:
datetime.now(timezone.utc)

For SQLAlchemy Column defaults, use lambda: datetime.now(timezone.utc).

Acceptance criteria

  • All utcnow() calls replaced
  • tox -e unit passes
  • No new deprecation warnings
## Description `datetime.utcnow()` is deprecated since Python 3.12 (PEP 587). It returns naive datetime objects that can cause subtle timezone bugs. ## Affected files - `src/timmy/mcp_tools.py` (line 199) - `src/dashboard/models/calm.py` (lines 43-44, 62) - `src/dashboard/routes/tasks.py` (lines 222, 290, 319, 361) - `src/dashboard/routes/work_orders.py` (lines 147, 214) ## Fix Replace all `datetime.utcnow()` with `datetime.now(timezone.utc)`: ```python from datetime import datetime, timezone # Before: datetime.utcnow() # After: datetime.now(timezone.utc) ``` For SQLAlchemy Column defaults, use `lambda: datetime.now(timezone.utc)`. ## Acceptance criteria - All `utcnow()` calls replaced - `tox -e unit` passes - No new deprecation warnings
Timmy closed this issue 2026-03-20 21:01:20 +00:00
Timmy reopened this issue 2026-03-20 21:06:21 +00:00
Timmy closed this issue 2026-03-20 21:51:32 +00:00
Author
Owner

Closing — all utcnow() references are already removed from source files. Only remnants in .pyc cache files. No action needed.

Closing — all `utcnow()` references are already removed from source files. Only remnants in `.pyc` cache files. No action needed.
Author
Owner

Verified: no datetime.utcnow() usage remains in the codebase. All instances have been migrated to datetime.now(UTC). Closing as already resolved.

Verified: no `datetime.utcnow()` usage remains in the codebase. All instances have been migrated to `datetime.now(UTC)`. Closing as already resolved.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#633