time-handling

Reviews datetime code for timezone awareness, UTC storage, and DST-safe calculations.

Updated Sep 2, 2026
One-click install
npx skills add https://github.com/Dazlarus/karl-code --skill time-handling-dazlarus
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: time-handling
Source: https://github.com/Dazlarus/karl-code/tree/main/.agents/skills/time-handling
Command: npx skills add https://github.com/Dazlarus/karl-code --skill time-handling-dazlarus

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires python-dateutil, croniter.

What problem does it solve? Datetime bugs are among the most common and costly software defects: naive datetimes, timezone mix-ups, and DST transition errors silently corrupt data and schedules. This Skill provides a structured review framework and best-practice patterns for writing correct time-handling code in Python. ## Core Features & Use Cases - Timezone-Aware Patterns: Enforces use of zoneinfo and timezone-aware datetimes instead of naive datetime.now() calls. - UTC Storage Convention: Guides storing timestamps in UTC and converting to local time only for display. - Robust Parsing & Calculation: Promotes ISO 8601 serialization, timedelta arithmetic, dateutil parsing, and DST fold handling. - Use Case: When reviewing a scheduling module, the Skill flags naive datetimes, manual second arithmetic, and missing DST handling, then suggests concrete fixes with code examples. ## Quick Start Review my datetime and scheduling code for timezone bugs and suggest fixes following time-handling best practices.

Frequently Asked Questions about time-handling

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

FAQPage Schema
How do I handle timezones correctly in Python?▼

Use timezone-aware datetimes with the zoneinfo module instead of naive datetime.now() calls. Create datetimes with datetime.now(timezone.utc) or ZoneInfo("America/New_York"), and convert between zones with astimezone().

Should I store datetimes in UTC or local time?▼

Store all datetimes in UTC and convert to the user's local timezone only for display. Keep the original timezone string alongside the UTC timestamp so you can reconstruct local times accurately.

What is the best way to parse date strings in Python?▼

Use dateutil.parser.parse() for flexible date parsing instead of strptime with fixed formats. Wrap parsing in try/except to handle invalid input gracefully, and validate timezone strings by attempting to construct a ZoneInfo object.

How do I handle DST transitions in datetime code?▼

Use zoneinfo timezones, which handle DST automatically during astimezone conversions. For ambiguous times during fall-back transitions, check the fold attribute to distinguish the first and second occurrence of a local time.

When should I not apply strict time-handling rules?▼

Skip the full checklist for simple logging timestamps, relative comparisons under one day, or cases where time accuracy is not critical. Over-engineering time handling adds complexity without benefit in those scenarios.