Skip to content

Commit 6f6dd46

Browse files
Fix datetime timezone issues in git_history.py
1 parent fd7bf74 commit 6f6dd46

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/codegen/extensions/attribution/git_history.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
22
from collections import defaultdict, deque
3-
from datetime import datetime
3+
from datetime import datetime, timezone
44
from typing import Optional
55

66
import pygit2
@@ -206,7 +206,7 @@ def map_symbols_to_history(self, force=False) -> None:
206206
start_time = time.time()
207207

208208
print("Stashing any working directory changes...")
209-
stash_msg = f"Codegen Attribution Stash @ {datetime.now().timestamp()}"
209+
stash_msg = f"Codegen Attribution Stash @ {datetime.now(timezone.utc).timestamp()}"
210210
stash_id = None
211211
try:
212212
stash_id = self.repo.stash(self.repo.default_signature, stash_msg, include_untracked=True)
@@ -423,12 +423,12 @@ def get_ai_contribution_timeline(self) -> list[tuple[datetime, int]]:
423423
if any(name in author for name in self.ai_authors):
424424
for commit in commits:
425425
# Convert timestamp to year-month
426-
dt = datetime.fromtimestamp(commit["timestamp"])
426+
dt = datetime.fromtimestamp(commit["timestamp"], timezone.utc)
427427
month_key = f"{dt.year}-{dt.month:02d}"
428428
monthly_counts[month_key] += 1
429429

430430
# Sort by date
431431
timeline = sorted(monthly_counts.items())
432432

433433
# Convert to datetime objects
434-
return [(datetime.strptime(month, "%Y-%m"), count) for month, count in timeline]
434+
return [(datetime.strptime(month, "%Y-%m").replace(tzinfo=timezone.utc), count) for month, count in timeline]

0 commit comments

Comments
 (0)