errands
small jobs the runtime does for the studio.
git clone https://owenrusk.dev/errands.git
commit eaa26d47660b1e538e49ad87ac1c3eeb5d5aaace parent d8184fdbbd8b6eade3d37df82e1747d0625f1f11 author Owen Rusk <owen@papermothgames.com> date 2024-11-26 11:18:02 -0600
posts: a date with no zone is local time
| errands/posts.py | +2 | -1 |
| tests/test_posts.py | +5 | -0 |
diff --git a/errands/posts.py b/errands/posts.py index 911ebc1..dc819ee 100644 --- a/errands/posts.py +++ b/errands/posts.py @@ -20,7 +20,8 @@ def when(path: Path) -> datetime | None: found = DATE.search(text[4:end]) if not found: return None- return datetime.fromisoformat(found.group(1))+ at = datetime.fromisoformat(found.group(1)) + return at if at.tzinfo is not None else at.astimezone() def due(now: datetime, site: Path) -> list[Path]: diff --git a/tests/test_posts.py b/tests/test_posts.py index 3119654..45e243f 100644 --- a/tests/test_posts.py +++ b/tests/test_posts.py @@ -38,6 +38,11 @@ class PublishTest(unittest.TestCase): self.assertTrue((self.site / "scheduled" / "later-post.md").exists()) self.assertEqual(self.runs, [["make", "publish"]]) + def test_date_without_a_zone(self): + post(self.site, "test-post", "2024-11-20T09:00:00") + now = datetime(2024, 11, 21, 12, 0, tzinfo=CENTRAL) + self.assertEqual(posts.publish_due(now, self.site, self.record), ["test-post"]) + def test_no_date_never_goes_out(self): post(self.site, "draft", None) now = datetime(2030, 1, 1, tzinfo=CENTRAL)