Mercurial > silorider
changeset 50:53d6c58a98e0
Fix problem with missing timezones, Bluesky doesn't like that.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 08 Oct 2023 13:48:48 -0700 |
parents | 2c433f19e467 |
children | b87217b90048 |
files | silorider/silos/bluesky.py |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/silorider/silos/bluesky.py Sun Oct 08 13:47:58 2023 -0700 +++ b/silorider/silos/bluesky.py Sun Oct 08 13:48:48 2023 -0700 @@ -25,11 +25,20 @@ # less identical. repo = self.me.did langs = [atprotomodels.languages.DEFAULT_LANGUAGE_CODE1] + + # Make sure we have a proper time zone. + post_datetime = post_datetime or datetime.datetime.now() + if not post_datetime.tzinfo: + tz_dt = datetime.datetime.now().astimezone() + post_datetime = post_datetime.replace(tzinfo=tz_dt.tzinfo) + created_at = post_datetime.isoformat() + + # Do it! data = atprotomodels.ComAtprotoRepoCreateRecord.Data( repo=repo, collection=atprotomodels.ids.AppBskyFeedPost, record=atprotomodels.AppBskyFeedPost.Main( - createdAt=datetime.datetime.now().isoformat(), + createdAt=created_at, text=text, facets=facets, embed=embed,