Skip to content

Fix resolve_time to be Pandas 3 compatible#14

Merged
seanshahkarami merged 1 commit into
mainfrom
fix-relative-timestamp
Jun 4, 2026
Merged

Fix resolve_time to be Pandas 3 compatible#14
seanshahkarami merged 1 commit into
mainfrom
fix-relative-timestamp

Conversation

@seanshahkarami
Copy link
Copy Markdown
Collaborator

I received a ticket from Greg Anderson (thank you!) pointing out that the way we resolve time fails as of Pandas 3, specifically here:

def resolve_time(t):
    try:
        return pd.to_datetime(t)          # Raises exception on "-2h" in Pandas <3, but returns Timestamp('1-01-01 02:00:00') in Pandas >=3
    except (TypeError, ValueError):
        pass
    return pd.to_datetime("now", utc=True) + pd.to_timedelta(t)

I think the simple fix Greg suggested of checking for a leading +/- is good and am adding that for string inputs.

@seanshahkarami seanshahkarami merged commit 5240698 into main Jun 4, 2026
9 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.

1 participant