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

推荐订阅源

T
Tenable Blog
MyScale Blog
MyScale Blog
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
博客园 - 司徒正美
D
Darknet – Hacking Tools, Hacker News & Cyber Security
量子位
N
News | PayPal Newsroom
S
Secure Thoughts
酷 壳 – CoolShell
酷 壳 – CoolShell
L
LINUX DO - 热门话题
有赞技术团队
有赞技术团队
V
Visual Studio Blog
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Project Zero
Project Zero
B
Blog RSS Feed
J
Java Code Geeks
Google Online Security Blog
Google Online Security Blog
Last Week in AI
Last Week in AI
Cyberwarzone
Cyberwarzone
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
博客园 - 【当耐特】
Latest news
Latest news
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
博客园_首页
博客园 - 三生石上(FineUI控件)
Engineering at Meta
Engineering at Meta
D
Docker
Forbes - Security
Forbes - Security
Help Net Security
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
The Last Watchdog
The Last Watchdog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threatpost
Cloudbric
Cloudbric
T
The Exploit Database - CXSecurity.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
Webroot Blog
Webroot Blog

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
Building a timezone-safe 52-week planning grid in React
Asef Ratul · 2026-06-18 · via DEV Community

A while ago I had to build a year-at-a-glance planning board: 52 weeks across the
top, grouped program rows down the side, each cell showing whether something is
scheduled that week. The kind of grid a field-service team, an agronomist, or a
maintenance crew plans a whole year on.

It looks like a table. It is not a table. It ate the better part of three weeks,
and almost none of that time went where I expected. Here are the parts that are
genuinely hard, with the approaches that finally worked — useful whether you're
building one yourself or just curious why "just a grid" is a trap.

1. There is no such thing as "52 weeks"

The first instinct is to render 52 columns. But a planning year is organised by
month, and months don't divide into weeks cleanly. You immediately hit two
different, equally valid models:

  • ISO-8601 weeks — real weeks, Monday-start, where a week belongs to the month that holds its Thursday. Accurate, but months get 4 or 5 weeks unevenly, and it shifts year to year.
  • A simple 4-4-5 pattern — the accounting-style calendar where each quarter is 4 + 4 + 5 weeks (52 total), identical every year. Predictable, but not "real" dates.

Different users want different ones, so the week count per month has to be a
strategy, not a constant:

type WeekStrategy = 'iso' | 'simple'

function weeksInMonth(monthIndex: number, cfg: PlannerConfig): number {
  if (cfg.weekStrategy === 'simple') {
    const pattern = cfg.simplePattern ?? [4, 4, 5]
    return pattern[monthIndex % pattern.length]
  }
  return isoWeeksInMonth(cfg.year, monthIndex) // 4 or 5, computed from dates
}

The moment "52" stops being hard-coded, the rest of the grid has to stop
assuming it too — column widths, headers, and cell lookups all derive from this.

2. The year doesn't start in January

Plenty of planning years don't start in January. A Southern-Hemisphere turf
program starts in July. A retailer's fiscal year might start in February. So the
column order can't be a fixed ['Jan', 'Feb', ...] array — it has to rotate from
a configurable start month:

interface PlannerConfig {
  year: number
  startMonth: number        // 1–12
  weekStrategy: WeekStrategy
  simplePattern?: number[]
  locale?: string
}

function buildColumns(cfg: PlannerConfig) {
  const cols = []
  for (let i = 0; i < 12; i++) {
    const monthOffset = cfg.startMonth - 1 + i
    const month = (monthOffset % 12) + 1
    const year = cfg.year + Math.floor(monthOffset / 12) // rolls into next year
    cols.push({ month, year, weeks: weeksInMonth(i, cfg) })
  }
  return cols
}

And the month labels should never be a hand-typed array either — that's a
localisation bug waiting to happen. Let the platform do it:

const label = new Intl.DateTimeFormat(cfg.locale ?? 'en', { month: 'short' })
  .format(new Date(year, month - 1, 1))

Now "July-start, en-AU" and "February-start, de-DE" both just work, and you
haven't written a single month name.

3. Never read the clock inside your logic

Here's the bug that will bite you in production but never in development:
highlighting the current week.

// ❌ reads the clock deep inside a pure-looking function
function isCurrentWeek(week: Week) {
  return week.start <= new Date() && new Date() < week.end
}

This breaks two ways. On the server (SSR / React Server Components) it computes a
different "now" than the client, and you get a hydration mismatch. And it makes
the function impossible to test deterministically — you can't unit-test "what
does week 12 look like on this date" if the function secretly asks the OS.

The fix is boring and powerful: inject "today" as a parameter. Your entire
date/week engine becomes pure — same inputs, same output, forever.

// ✅ deterministic and SSR-safe
function isCurrentWeek(week: Week, today: Date) {
  return week.start <= today && today < week.end
}

Push the single new Date() to the very edge of the app (one prop at the top),
and everything below it is testable and timezone-safe.

4. Season bands wrap around the year boundary

If you colour the header by season, you hit a subtle one. In a July-start year,
"Winter" might be June–August. But June is the last column and July–August are
the first two. So a single season band has to render as two segments — one
at each end of the grid — without you special-casing it.

The trick is to define a band by the set of months it covers, then let the
column builder place segments wherever those months landed after rotation:

interface SeasonBand { id: string; label: string; months: number[]; color: string }

// After buildColumns(), group *contiguous runs* of columns whose month is in the
// band. A band split by the fiscal boundary naturally yields two runs.

Define seasons as data, derive the visual segments from the rotated columns, and
the wrap-around handles itself. Hard-code the spans and you'll be patching edge
cases forever.

5. Sticky headers, and not re-rendering 4,000 cells

Two performance/UX notes that cost real time:

  • Sticky in two axes at once. Row labels stick left, the season/month/week header sticks top, and they have to cooperate while scrolling. Getting position: sticky to behave in both directions across Chrome, Safari, and Firefox is fiddlier than it sounds — test all three early.
  • Don't re-render the whole grid on one cell change. A 60-row × 64-week board is ~4,000 cells. If toggling one cell re-renders all of them, dragging feels awful. Memoise at the row level and key cells stably so a single edit touches a single row.

6. Print is a feature, not an afterthought

The thing users actually asked for, that I budgeted zero time for: a printable
wall chart. A superintendent wants to pin the whole year to the shed wall.

Print is its own layout problem. You want an @page setup for A3/A4 in portrait
and landscape, column density tuned so a full year fits the page width, and
section rows that never split across a page break:

@media print {
  @page { size: A3 landscape; }
  .section-group { break-inside: avoid; }
  .app-chrome { display: none; }   /* hide nav/buttons; print only the board */
}

It demos beautifully and it's the part people remember — but it's a day of work
on its own, separate from the on-screen grid.

The principle underneath all of it

The thing that made the whole build sane: separate the logic from the
presentation.
All the week math, column rotation, season banding, and status
logic live in pure functions with no JSX, no DOM, and no clock reads. The React
components are a thin rendering layer on top. That split is what makes the engine
testable (I got the core to ~99% coverage), SSR-safe, and reusable across totally
different domains — the same grid renders a turf program, a pest-control route
schedule, or a maintenance plan, just from different data.

If you're building one of these, budget for the six things above — they're where
the time actually goes.


I packaged this grid engine as a commercial Next.js template called
SeasonBoard — config-driven, type-safe, with the print layout and headless core described here.

If you'd rather not spend the three weeks, it'll save you most of them. Either
way, I hope the breakdown above saves you some pain.