- Home
- Skills
- APIs & Backend
- timezone handling
timezone handling
Enforce UTC-based storage and IANA-compliant timezone handling to eliminate DST bugs and production offset errors.
Free
Works with the AI Agents you already use
timezone handling
Example session with this skill installed
We are seeing a bug where our appointments are off by 7 hours in the production logs compared to local dev. The database uses PostgreSQL. Review our approach.
- Read your context and instructions
- Compiled the timezone handling
I have reviewed your timezone handling. The 7-hour discrepancy indicates a classic offset bug caused by using naive timestamps in an environment where the local server time differs from the database or container default.
Timezone Handling Audit
| Component | Current Issue | Recommended Fix |
|---|---|---|
| Database Column | Likely TIMESTAMP (naive) | Alter column to TIMESTAMPTZ to store absolute instants. |
| App Logic | Using datetime.now() | Replace with datetime.now(timezone.utc) for aware objects. |
| Container Config | Inheriting host TZ | Set TZ=UTC in your Dockerfile/environment variables. |
| Display Layer | Rendering raw DB values | Use IANA zone (e.g., Asia/Bangkok) only at the final UI edge. |
Corrected Code Pattern (Python/SQL)
-- Schema Migration
ALTER TABLE appointments
ALTER COLUMN start_time TYPE TIMESTAMPTZ;
# Application Logic
from datetime import datetime, timezone
import zoneinfo
# 1. Capture/Compute in UTC
appointment_instant = datetime.now(timezone.utc)
# 2. Persist to TIMESTAMPTZ column
db.execute("INSERT INTO appointments (start_time) VALUES (%s)", (appointment_instant,))
# 3. Convert only at the edge for display
user_tz = zoneinfo.ZoneInfo("Asia/Bangkok")
display_time = appointment_instant.astimezone(user_tz)
print(f"Your appointment is at: {display_time.strftime('%H:%M %Z')}")
Next steps
- Verify the current
TZenvironment variable in your production containers. - Update the database schema to
TIMESTAMPTZto ensure the DB interprets incoming values as UTC. - Audit the codebase for any
utcnow()calls, as these return naive objects that cause drift.
Connects securely to your tools. The creator never sees your data.
About this skill
Timezone bugs often go unnoticed until production, where mismatched server clocks or Daylight Saving Time (DST) shifts corrupt your data. This skill provides a rigorous protocol for handling instants, wall-clocks, and scheduling across distributed systems.
What it does
- Database schema design recommends correct types like
TIMESTAMPTZover naiveTIMESTAMPto prevent offset drift. - Application logic auditing identifies dangerous naive datetime calls and replaces them with timezone-aware UTC objects.
- Scheduling logic manages recurring events in DST-affected regions by anchoring to IANA zone names rather than fixed offsets.
- Environment hardening configures container and server
TZvariables to ensure consistency across dev, CI, and production. - Data modeling distinguishes between absolute instants and "date-only" values like birthdays to avoid date-boundary errors.
How it works
- Audit storage and computation to ensure all temporal data is persisted and processed in UTC.
- Implement edge conversion by identifying where user input is parsed and where data is rendered for display.
- Apply IANA zone naming to replace hardcoded offsets, ensuring automatic adjustment for DST transitions.
- Validate domain-specific windows such as market hours or cron jobs against their native local zones before converting to UTC.
Frameworks & tools
This skill applies to any stack dealing with persistence and scheduling, including PostgreSQL, Python, Node.js, and Docker environments.
Why this beats prompting it yourself
Generic AI models often suggest utcnow() or fixed offsets, which are known footguns in production. This skill enforces a "UTC-at-rest" architecture that accounts for DST overlaps and environment-specific clock drift that simple prompts usually miss.
Use cases
- Debugging timestamps that are off by a fixed number of hours in production.
- Designing a global scheduling system that must respect local 9:00 AM start times.
- Migrating a legacy database from naive timestamps to timezone-aware storage.
- Implementing financial market open/close logic that adjusts for US/EU DST shifts.
Known limitations
This skill focuses on wall-clock time and calendar scheduling. It is not intended for measuring high-precision elapsed time or durations, where a monotonic clock is required.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean today
- Free to download with an account