fix: correct timestamp parsing bug - chained .replace() was stripping timezone

The chained .replace("Z", "+00:00").replace("+00:00", "") calls were
undoing each other, causing Z-suffixed timestamps to lose timezone info.
Now strips "Z" directly and ensures naive datetime for cutoff comparison.
Added regression test for old Z-suffixed timestamps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Claude Code
2026-04-01 16:07:34 -05:00
parent 355986a59f
commit 2801a63b11
2 changed files with 11 additions and 1 deletions

View File

@@ -64,7 +64,7 @@ def filter_memories_by_time(memories: List[Dict], hours: int = 24) -> List[Dict]
try:
# Parse ISO timestamp
if isinstance(ts, str):
mem_time = datetime.fromisoformat(ts.replace("Z", "+00:00").replace("+00:00", ""))
mem_time = datetime.fromisoformat(ts.replace("Z", "")).replace(tzinfo=None)
else:
mem_time = ts
if mem_time > cutoff: