๐Ÿก 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.