{
  "id": 6612643,
  "title": "new Date('2026-03-01') is 28 February if your user is in California",
  "url": "https://urgent.news/2026/09/10/new-date-2026-03-01-is-28-february-if-your-user-is-in-california",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-10T16:53:22.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/thedolceway/new-date2026-03-01-is-28-february-if-your-user-is-in-california-5h6b"
  },
  "original_language": "en",
  "account": "A powerful tool for generating resignation or notice letters relies on a simple date formatting function. The function relies on converting a date string into a Date object, which then formats the date according to the user's locale. However, this seemingly innocuous piece of code harbors a dangerous bug.\n\nWhen the function receives a date string in the format YYYY-MM-DD, it converts it into a Date object using new Date(). This conversion assumes the string represents a UTC date. When parsed as UTC, the date 2026-03-01 becomes midnight on 28 February in California, which leads to the incorrect letter stating the last working day as 28 February instead of the correct date, 1 March.\n\nThe bug stems from ECMAScript's specification that date-only ISO strings are parsed as UTC. This means that any date string not following the date-only ISO format, such as 2026/03/01 or 2026-02-31, is parsed as local time, which can lead to incorrect results. The function's Number.isNaN guard is supposed to catch parsing errors, but it fails to detect overflow dates like 30 February, which silently rolls forward to the next month.\n\nMoreover, the function does not handle daylight-saving time transitions properly. For instance, adding two weeks to 25 October 2026 in Los Angeles yields either 7 or 8 November, depending on the arithmetic used. This inconsistency can cause significant issues in a notice-period feature, where adding two weeks should always result in a precise date.\n\nTo avoid these problems, the function should stop parsing strings as dates and avoid using UTC in calendar calculations. Instead, it should convert the input string into a Date object using the local construction, perform calendar calculations using days instead of milliseconds, and return the formatted date using the user's locale settings. By taking these precautions, the tool can reliably generate accurate resignation and notice letters without confusing the user or compromising the integrity of the process.",
  "summary": "We build a tool that turns a few form fields into a finished resignation or notice letter. The single most important string in that output is a date. A resignation letter states your last working day, and that date is the thing your employer acts on. So the date formatting code is four lines and it is the most dangerous four lines in the feature. function formatDate ( value ) { if ( ! value .…",
  "key_points": [
    "Function converts date string to Date object using new Date()",
    "Bug arises from UTC parsing, making 2026-03-01 equal 28 February in California",
    "Tool should use local construction, days-based calculations to avoid issues"
  ],
  "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."
}