惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tor Project blog
V2EX - 技术
V2EX - 技术
S
Security Affairs
Help Net Security
Help Net Security
Webroot Blog
Webroot Blog
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
T
Threat Research - Cisco Blogs
Scott Helme
Scott Helme
IT之家
IT之家
W
WeLiveSecurity
U
Unit 42
博客园 - 聂微东
Vercel News
Vercel News
爱范儿
爱范儿
GbyAI
GbyAI
H
Hacker News: Front Page
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
PCI Perspectives
PCI Perspectives
博客园 - 三生石上(FineUI控件)
博客园_首页
T
Tailwind CSS Blog
有赞技术团队
有赞技术团队
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Security Blog
Microsoft Security Blog
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
A
About on SuperTechFans
Cloudbric
Cloudbric
博客园 - 叶小钗
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
Troy Hunt's Blog
The GitHub Blog
The GitHub Blog
A
Arctic Wolf
Latest news
Latest news
AWS News Blog
AWS News Blog
MongoDB | Blog
MongoDB | Blog
量子位
Spread Privacy
Spread Privacy
D
DataBreaches.Net
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
Recorded Future
Recorded Future
T
Threatpost
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
2026 Has 53 Weeks. Here's the Bug That's About to Surface.
What Week Is It · 2026-06-01 · via DEV Community

TL;DR 2026 is a 53 week year (ISO 8601). If anything in your stack assumes a year has 52 weeks a % 52, a fixed length array, a chart axis, a weekly aggregation it has a latent bug that this year will trigger. Don't hard code 52. Here's how to spot it and fix it.

Quick gut check before you read on: how many weeks are in a year?

If you answered 52, you're right about 80% of the time. The other 20% of the time there are 53, and the code that assumed 52 does something quietly wrong drops a week of data, wraps a counter, throws an index error, or labels two different weeks with the same number. 2026 is one of those years, which makes this a good moment to go find that bug before it finds you.

Wait, how can a year have 53 weeks?

ISO 8601 weeks start on Monday, and a week belongs to whichever year holds its Thursday. Stack 52 of those and you get 364 days one short of a normal year, two short of a leap year. That leftover day accumulates, and every so often the calendar pays off its debt with a 53rd week.

Mechanically, a year gets 53 ISO weeks when January 1st falls on a Thursday, or on a Wednesday in a leap year. That works out to roughly once every five or six years:

... 2015, 2020, 2026, 2032, 2037 ...

Enter fullscreen mode Exit fullscreen mode

2026 qualifies because January 1st, 2026 is a Thursday. So this year runs Monday weeks 1 through 53, and the calendar genuinely has a week 53 sitting in late December. It is not an off-by-one in your head it's the standard.

The previous 53 week year was 2020. If your codebase is younger than that, it has very possibly never executed against a 53 week year in production. That's exactly the kind of edge case that ships green and breaks live.

Where it actually bites

This is rarely a dramatic crash. It's the quiet, plausible looking wrongness that survives code review. A few real shapes it takes:
1. The modulo that wraps. Anything doing week math with % 52 collapses week 53 onto week 1:

const slot = weekNumber % 52; // week 53 -> slot 1, silently merged with week 1

Enter fullscreen mode Exit fullscreen mode

Now week 1 and week 53 land in the same bucket. Your year-end aggregate double-counts, and your January numbers look inexplicably high.

2. The fixed-length structure. A new Array(52), a 52-column table, a 52-element enum, a chart with 52 ticks. Week 53 either overflows, gets truncated, or throws:

const weeklyTotals = new Array(52).fill(0);
weeklyTotals[week - 1] += amount; // week === 53 -> index 52 -> undefined slot

Enter fullscreen mode Exit fullscreen mode

3. The week-over-week comparison. "This week vs. the same week last year" assumes both years have the same weeks. 2025 (52 weeks) vs. 2026 (53 weeks) don't line up, and your YoY dashboard quietly misaligns by the end of December.

4. The off-by-one cousin. Closely related and worth knowing: a week can belong to a different year than its calendar dates suggest. January 1st, 2027 is actually week 53 of 2026, not week 1 of 2027. If you ever pair an ISO week with getFullYear() instead of the ISO week-numbering year, that's a separate bug hiding right next to this one. (Different rabbit hole; the ISO week number guide covers it if you want the full mechanics.)

Detecting a 53-week year in code

You don't need a lookup table. There's one date that is always in the final ISO week of its year: December 28th. So the week number of December 28th tells you how many weeks the year has:

function isoWeek(date) {
  const d = new Date(date);
  d.setHours(0, 0, 0, 0);
  // jump to the Thursday of this ISO week
  d.setDate(d.getDate() + 3 - ((d.getDay() + 6) % 7));
  const week1 = new Date(d.getFullYear(), 0, 4);
  return 1 + Math.round(
    ((d - week1) / 86400000 - 3 + ((week1.getDay() + 6) % 7)) / 7
  );
}

function weeksInYear(year) {
  return isoWeek(new Date(year, 11, 28)); // Dec 28 -> last week of the year
}

weeksInYear(2025); // 52
weeksInYear(2026); // 53
weeksInYear(2027); // 52

Enter fullscreen mode Exit fullscreen mode

Most date libraries ship this too reach for their getISOWeeksInYear-style helper rather than rolling your own, and pull the week-numbering year from the library instead of the plain calendar year.

Fixing it without playing whack-a-mole

The fix is the same idea everywhere: stop treating 52 as a constant. Concretely:

  • Size structures dynamically: new Array(weeksInYear(year)), not new Array(52).
  • Drop the % 52. If you're bucketing by week, key on the {isoYear, isoWeek} pair so week 53 and the next year's week 1 can never collide.
  • For YoY comparisons, align on the ISO week label, and decide explicitly what to do with the orphan 53rd week (carry it, or compare W53 against the prior year's W52 - just make it a deliberate choice).
  • Add a test that runs your week logic against a known 53-week year. 2026 and 2020 are free test fixtures.
test("handles 53-week years", () => {
  expect(weeksInYear(2026)).toBe(53);
  expect(bucketsFor(2026)).toHaveLength(53); // not 52
});

Enter fullscreen mode Exit fullscreen mode

If you want a CI canary, a one-line guard that logs when the current year has 53 weeks is a cheap way to get a heads-up the next time this rolls around (2032).

When you'd rather not own the logic at all

For a lot of cases - a status badge, a Slack reminder, a report header, a cron that needs "is this a long year?" - shipping date arithmetic is more risk than it's worth. There's a free, no-key JSON API that returns the week info for any date, and it hands you the 53-week answer as a plain boolean so you don't have to derive it:

const res = await fetch("https://weekisit.com/api/week");
const data = await res.json();

data.iso_week;          // 22
data.total_weeks_in_year; // 53
data.is_53_week_year;     // true  <-- the whole problem, as one field

Enter fullscreen mode Exit fullscreen mode

That is_53_week_year flag is doing exactly the job of the weeksInYear function above, minus the maintenance. The endpoint is CORS-enabled, so you can call it straight from front-end code; just cache the result, since the answer only changes once a year.

The 53-week year is bigger in finance than you think

If you work anywhere near retail, billing, or reporting, this isn't a curiosity - it's a scheduled event. The 4-4-5 retail calendar (and the NRF's 4-5-4 variant) is built on 52-week years of exactly 364 days, and it deliberately inserts a 53rd week every five or six years to resync with the actual calendar. Whole quarters of financial comparison hinge on whether a given year is a 52- or 53-week year. If your data model serves finance, the fiscal calendar breakdown is worth a read before you hard-code anything.

Takeaways

  • 2026 has 53 ISO weeks. The previous one was 2020; the next is 2032.
  • A year has 53 weeks when Jan 1 is a Thursday (or a Wednesday in a leap year).
  • Never treat 52 as a constant: no % 52, no fixed 52-length structures, no naive YoY alignment.
  • Bucket by the {isoYear, isoWeek} pair so week 53 never collides with anyone's week 1.
  • Test against 2026 and 2020, or offload the question entirely with a single is_53_week_year boolean.

Week numbers feel like the most boring possible part of date handling, right up until a 53-week year turns a one-character assumption into a year-end incident. Spend ten minutes grepping your codebase for 52 this week. Future-you, sometime around late December, will be grateful.