{
  "id": 338183,
  "title": "Counting the days, revisited",
  "url": "https://urgent.news/2026/08/09/counting-the-days-revisited",
  "topic": "ai",
  "section": "AI",
  "published": "2026-08-09T02:32:55.000Z",
  "source": {
    "name": "Lobsters",
    "slug": "lobsters",
    "url": "https://dotat.at/@/2026-08-09-rata-die.html"
  },
  "original_language": "en",
  "account": "The algorithm for converting Gregorian dates to Julian Day numbers was previously written but has been improved since. The main formula counts days before the year's start, adjusting for leap days and the unusual alignment of January and February at the end of the previous year. This adjustment allows the leap day in year 4 to be counted correctly at the beginning of the adjusted year. The function is then able to utilize more of its output data type's range. The next part corrects the number of leap years before the current year, similar to the Julian leap year calculation but requiring a more complex approach. Modern compilers can turn divisions into simple shifts, making the code more efficient. Finally, the number of days in the current (adjusted) year before the start of the month is calculated. The expression is improved by converting it into a multiply-and-shift operation, rather than using compiler optimizations that may not be as efficient. The epoch can be adjusted based on the desired starting point, such as the MJD or Unix epochs. Unsigned integers are recommended for these calculations to avoid misleading results for dates before year 1. Additionally, a faster leap year test is proposed, which checks divisibility by 25 and 16, or by 4 but not 25, using fewer comparisons and potentially improving performance.",
  "summary": null,
  "key_points": [
    "Improved algorithm counts Gregorian dates to Julian Day numbers",
    "Adjusts for leap days, aligns January and February correctly",
    "Optimized calculations using multiply-and-shift operations"
  ],
  "editors_take": "Improved date conversion algorithms enable more efficient and accurate calculations, allowing for better handling of leap years and larger date ranges, while also offering optimization opportunities.",
  "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."
}