Skip to content

fix: make datetimes tz-aware to avoid naive/aware mix errors#276

Merged
Vinsho merged 1 commit into
masterfrom
fix/utcnow-tz-aware-datetime
Jun 25, 2026
Merged

fix: make datetimes tz-aware to avoid naive/aware mix errors#276
Vinsho merged 1 commit into
masterfrom
fix/utcnow-tz-aware-datetime

Conversation

@Vinsho

@Vinsho Vinsho commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Replace naive datetime.utcnow() with datetime.now(timezone.utc) in FetchResult.time and the NftOffer.start_time fallback, add tz=utc to unisat's fromtimestamp (which also fixes a local-offset shift), and make parse_dt always return a tz-aware datetime (assume UTC for strings without a timezone) so it is consistent with its numeric paths.

This prevents "can't subtract offset-naive and offset-aware datetimes" downstream when these values are compared/subtracted. Updates 3 tests that asserted the old naive behaviour and documents the two spots (DebankProtocolCache, v1 RateLimit) that stay naive on purpose.

Replace naive datetime.utcnow() with datetime.now(timezone.utc) in
FetchResult.time and the NftOffer.start_time fallback, add tz=utc to
unisat's fromtimestamp (which also fixes a local-offset shift), and make
parse_dt always return a tz-aware datetime (assume UTC for strings
without a timezone) so it is consistent with its numeric paths.

This prevents "can't subtract offset-naive and offset-aware datetimes"
downstream when these values are compared/subtracted. Updates 3 tests
that asserted the old naive behaviour and documents the two spots
(DebankProtocolCache, v1 RateLimit) that stay naive on purpose.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Vinsho Vinsho requested a review from galvanizze June 25, 2026 13:10
@Vinsho Vinsho merged commit 3c8ae3d into master Jun 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants