{
  "id": 605895,
  "title": "Stop Reinventing the Wheel: A QA Pattern for Date Math in User-Facing Code",
  "url": "https://urgent.news/2026/08/11/stop-reinventing-the-wheel-a-qa-pattern-for-date-math-in-user-facing",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-08-11T22:04:31.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/lizely/stop-reinventing-the-wheel-a-qa-pattern-for-date-math-in-user-facing-code-4kb7"
  },
  "original_language": "en",
  "account": "Backend systems often repeat the same date arithmetic code, leading to bugs. A quick example is calculating age by subtracting birth year from current year. This fails for people born on February 29 during leap years. The article provides a checklist for engineers to harden date math in user-facing code. The first step is to answer the business two questions: what full years have passed and what duration thresholds have been crossed? The second step is to commit a matrix of test cases to the code repository that covers various edge cases. The third step is to refactor the age computation so the reference date is a parameter, defaulting to now() only at the public interface. This eliminates the now hidden inside the function being tested. The article also discusses how time-of-day components can affect eligibility rules, recommending to strip the time component at the boundary for comparison.",
  "summary": "Every backend that touches a date of birth ends up reinventing the same arithmetic. I've watched it happen in three codebases this year alone: a fintech KYC service, a healthcare intake portal, and a small HR tool for a startup. The bug shape is almost always identical — somebody computes age by subtracting birth year from current year, the QA suite passes because it only tests inputs born in…",
  "key_points": [
    "Engineers should answer business questions about full years passed and duration thresholds.",
    "Create a matrix of test cases covering edge cases in the code repository."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}