{
  "id": 19912826,
  "title": "date -d \"-1 month\" Named the Current Month on Seven Days of 2026: Picking Last Month's Camera Clip Folder in Bash",
  "url": "https://urgent.news/2026/11/14/date-d-1-month-named-the-current-month-on-seven-days-of-2026-picking",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-14T03:54:30.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/superfunicular/date-d-1-month-named-the-current-month-on-seven-days-of-2026-picking-last-months-camera-clip-p91"
  },
  "original_language": "en",
  "account": "A bash script tests three methods for naming the previous month's folder in the context of a phone camera job. The script runs on each day of 2026, comparing the output of each method against the real previous month. It finds that the simple \"date -d -1month\" method is accurate on 358 days of the year, while the other two methods (\"1 month ago\" and \"last month\") fail on 7 days. The failures occur due to the script keeping the day of the month, changing the month number, and then normalizing the result. This causes issues when the previous month does not have enough days (e.g., March 31st points to March). The script also tests this issue for the upcoming year, finding similar problems with the \"+1 month\" method skipping February.",
  "summary": "A monthly job for a phone camera packs up last month's clip folder, clips/2026-02 say, and frees the space. The usual way to get that folder name in a shell script is date -d -1month +%Y-%m , or the same thing spelled with a space inside quotes. I ran that line against every day of 2026. On seven days it names the current month, which is the folder the camera is still writing to. The test The…",
  "key_points": [
    "Simple date -d -1month method accurate on 358 days of 2026",
    "Other two methods (1 month ago, last month) fail on 7 days",
    "Failures due to script keeping day of month and normalizing result"
  ],
  "editors_take": "Relying on simple date arithmetic for folder naming creates edge-case errors during month transitions, forcing developers to account for varying month lengths to avoid incorrect directory paths.",
  "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."
}