You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
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!
The text was updated successfully, but these errors were encountered:
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 postpost.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 thetimezone.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!
The text was updated successfully, but these errors were encountered: