digital-craftsman/date-time-precision
Thin PHP value objects for precise date/time concepts: Moment (UTC-backed) plus Time, Date, Month, Year, Day, Weekday and collections. Avoid misleading DateTime comparisons, handle timezone-safe modifications (DST), with Symfony normalizers and Doctrine types.
Time, Date, Month, Year) without timezone ambiguity or redundant data. Ideal for scheduling, booking, or event-based systems where granularity matters (e.g., "Is this time within business hours?" or "Is this date before the booking deadline?").Date instead of DateTime for non-temporal fields) and avoiding timezone-related bugs in queries.FrozenClock simplifies time-based testing (e.g., unit tests for time-sensitive workflows like subscriptions or deadlines).DateTime usage in monolithic apps where date logic is scattered and error-prone.Carbon extensions or ad-hoc solutions) while offering more structure than vanilla PHP.Adopt When:
DateTime pitfalls.FrozenClock for predictable tests).Look Elsewhere If:
DateTime)."This package lets us handle dates and times with surgical precision—like using a scalpel instead of a chainsaw. For example, instead of storing a full DateTime for a booking deadline (which includes irrelevant time/zone data), we store just the Date. This reduces bugs, cuts storage costs, and makes time-sensitive features (like scheduling or subscriptions) more reliable. It’s a low-risk upgrade that aligns with our UTC-first architecture and will save dev time long-term."
Key Outcomes:
*"This replaces PHP’s clunky DateTime with immutable value objects (Moment, Time, Date, etc.) that:
Moment in UTC but lets you modify/compare in any timezone.Date field won’t accidentally include time/zone data.FrozenClock replaces Time::freeze() hacks.Example Win:
// Before (error-prone):
if ($user->createdAt->format('Y-m-d') < $cutoffDate) { ... }
// After (safe & explicit):
if ($user->createdAt->isBeforeInTimeZone($cutoffDate, $userTimezone)) { ... }
Tradeoffs:
Call to Action: "Let’s pilot this in the booking system first—it’s where we’ve seen the most timezone bugs. If it reduces support tickets by 20%, we’ll roll it out to other date-heavy modules."
How can I help you explore Laravel packages today?