time-zone-safety

Detects and corrects unsafe current-time calls and timezone handling in server-side code.

1.0k|109|Updated Jan 4, 2026
One-click install
npx skills add https://github.com/doccker/cc-use-exp --skill time-zone-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: time-zone-safety
Source: https://github.com/doccker/cc-use-exp/tree/main/.cursor/skills/time-zone-safety
Command: npx skills add https://github.com/doccker/cc-use-exp --skill time-zone-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Bare calls like LocalDate.now(), new Date(), or time.Now() depend on the JVM or OS default timezone, so the same code produces different results on a developer machine (Asia/Shanghai) and a production container (UTC), causing week/month/day boundary statistics to drift by hours.

Core Features & Use Cases

  • Bare .now() Detection: Provides grep-based sniffing commands to find LocalDate.now(), LocalDateTime.now(), new Date(), Date.now(), and time.Now() across Java, Go, Python, and TypeScript codebases.
  • Boundary Calculation Rules: Shows correct patterns for computing week start, month start, and day start with an explicit business timezone constant (BIZ_ZONE).
  • Database Timezone Alignment: Covers JDBC serverTimezone settings, DATETIME vs TIMESTAMP column strategy, and Docker TZ pinning to keep the application and database layers consistent.
  • Use Case: A daily order statistics query returns no rows after midnight deployment because the server runs UTC while the database stores Asia/Shanghai times; this Skill walks through fixing the query boundary, JDBC URL, and container timezone.

Quick Start

Review my Java service for unsafe LocalDate.now() and week-start calculations and rewrite them to use an explicit Asia/Shanghai business timezone.

Frequently Asked Questions about time-zone-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix LocalDate.now() timezone bugs in Java?

Pass an explicit ZoneId such as ZoneId.of("Asia/Shanghai") to every LocalDate.now(), LocalDateTime.now(), and atStartOfDay() call. Define a shared BIZ_ZONE constant in a TimeConstants class so all boundary calculations use the same business timezone.

Why does my daily statistics query return wrong results in production?

Production containers often default to UTC while development machines use the local timezone, so day boundaries shift by hours. Fix it by computing boundaries with an explicit business timezone and aligning the JDBC serverTimezone and database column type.

Should I use DATETIME or TIMESTAMP in MySQL for timezone safety?

Use DATETIME with serverTimezone=Asia/Shanghai and LocalDateTime fields for single-timezone business systems, or TIMESTAMP with serverTimezone=UTC and Instant fields for cross-timezone SaaS. Never mix DATETIME columns with a UTC JDBC connection.

How do I handle timezones in Go and Python time.Now calls?

In Go, load the location with time.LoadLocation("Asia/Shanghai") and call time.Now().In(loc). In Python, use datetime.now(tz=ZoneInfo("Asia/Shanghai")) to get an aware datetime instead of a naive one.

How do I compare user-submitted time strings with database timestamps?

Parse the user string as a LocalDateTime, attach the declared business timezone with atZone(BIZ_ZONE), and convert to Instant before comparing. Always compare across timezones using Instant rather than LocalDateTime to avoid implicit JVM timezone conversion.