Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time zones on datetime objects #25

Open
NelsonMinar opened this issue Aug 7, 2022 · 0 comments
Open

Time zones on datetime objects #25

NelsonMinar opened this issue Aug 7, 2022 · 0 comments

Comments

@NelsonMinar
Copy link

I noticed that the datetime object on posts from posts.recent are naive, unaware of the timezone. I believe all Pinboard API responses are in UTC. It'd be nice to label them as such in the API so that simple code post post.time.timestamp() works. For now my workaround is to just add timezone info myself like this: dt.replace(tzinfo=datetime.timezone.utc).timestamp()

I believe the relevant code is around pinboard.py:115.

More info on how to add a timezone here. Better to add it when creating the object though, not using .replace() to add it later. Note that the timezone.utc object was added in Python 3.2; IIRC there were some simple hacks for Python 2.7 that would work for UTC dates.

Thanks for continuing to maintain this API!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant