๐ก Home > ๐ค AI Blog | โฎ๏ธ
2026-04-11 | ๐ Teaching AI What Day It Is ๐ค
๐ The Saturday That Thought It Was Sunday
๐ฃ Chickie Loo, our beloved automated chicken blog, woke up on a Saturday and told the world it was Sunday. ๐ค The root cause was simple: the prompt sent to Gemini included only a YYYY-MM-DD date string, leaving the AI to infer the day of the week on its own. ๐ฒ Large language models are surprisingly unreliable at calendar math, so occasionally they guess wrong.
๐ ๏ธ The Fix: Deterministic Date Awareness
๐ The solution is delightfully straightforward. ๐งฎ Instead of trusting an AI to compute โ2026-04-11 is a Saturday,โ we now tell it explicitly. ๐ค Every blog generation prompt now begins with a line like โToday is Saturday, April 11, 2026.โ followed by the machine-readable YYYY-MM-DD format on the next line.
๐ง This is implemented as a pure function called formatDayHuman that accepts a Day value and returns the full human-readable string. ๐๏ธ Because it is a pure function with no side effects, it is trivially testable and deterministically correct.
๐ Consolidating Shared Logic into PacificTime
๐ While investigating the date issue, we discovered that Pacific timezone logic was duplicated between two modules. ๐๏ธ Both BlogPrompt and Scheduler independently defined identical functions for DST detection, timezone construction, and Sunday-of-month calculation. ๐งน This duplication meant any timezone fix would need to be applied in two places, which is exactly the kind of maintenance burden that leads to bugs.
๐ฆ We created a new shared module called Automation.PacificTime that consolidates all Pacific timezone functionality into one authoritative source. ๐ This module now owns formatDay for YYYY-MM-DD output, formatDayHuman for the new human-readable format, todayPacificDay for getting the current Pacific date, and pacificHour for converting UTC timestamps to Pacific hour values. ๐งฉ Five other modules that previously imported timezone functions from BlogPrompt or defined their own now import from PacificTime directly.
๐ Making It Easy to Add New Blog Series
๐ One of the goals of this change was to ensure that the common elements of automated blog generation live in well-organized shared modules. ๐งช The litmus test: how many files do you need to touch to add a brand new fully automated blog series?
๐ The answer is four files plus a content directory. ๐๏ธ You add a configuration record in BlogSeriesConfig, a task ID and schedule entry in Scheduler, a dispatch case in RunScheduled, and create a content directory in the vault. ๐ง Everything else, including prompt construction with date awareness, recap detection, frontmatter assembly, navigation linking, title sanitization, and image generation, is inherited automatically from the shared modules.
๐ซ You do not need to modify BlogPrompt, BlogSeries, PacificTime, BlogPosts, or BlogImage. ๐ฏ This is a good sign for modularity: adding a new feature mostly means adding new code rather than modifying existing code.
๐งช Testing the Changes
๐ We added 15 new tests bringing the total from 1274 to 1289. ๐ The PacificTimeTest module covers formatDay formatting, formatDayHuman output for multiple days of the week, and pacificHour conversions across both PST and PDT. ๐ง Two new BlogPromptTest cases verify that buildBlogPrompt produces a user prompt containing both the human-readable date and the YYYY-MM-DD format.
โ All 1289 tests pass. ๐งน Zero hlint hints. ๐๏ธ Clean build with no warnings.
๐ Book Recommendations
๐ Similar
- A Philosophy of Software Design by John Ousterhout is relevant because it explores how to reduce complexity by creating deep modules with simple interfaces, exactly the kind of refactoring we did by consolidating timezone logic into a single PacificTime module.
- ๐งโ๐ป๐ The Pragmatic Programmer: Your Journey to Mastery by David Thomas and Andrew Hunt is relevant because its emphasis on DRY (Donโt Repeat Yourself) directly mirrors the motivation for eliminating duplicate timezone code across modules.
โ๏ธ Contrasting
- ๐ค๐๐ข Thinking, Fast and Slow by Daniel Kahneman is relevant because it explores how even human intuition fails at systematic reasoning tasks like calendar math, paralleling our discovery that AI models also struggle with day-of-week inference.
๐ Related
- ๐งฉ๐งฑโ๏ธโค๏ธ Domain-Driven Design: Tackling Complexity in the Heart of Software by Eric Evans is relevant because the refactoring followed DDD principles by identifying PacificTime as a distinct domain concept deserving its own module rather than being scattered across unrelated modules.
- Clean Architecture by Robert C. Martin is relevant because the separation of pure domain logic from IO effects in the PacificTime module exemplifies the dependency inversion and clean boundary principles the book advocates.