aeon-php/calendar
Aeon Calendar is a time management framework for PHP that makes working with dates, times, time zones, and intervals easier through a clean, object-oriented API, backed by solid testing and clear documentation with examples.
Strengths:
isMidnight(), isNotMidnight(), and compareTo() improve usability for time-based logic (e.g., scheduling, event validation).Time, Day, Month) decouples construction from behavior, reducing side effects in concurrent environments.Weaknesses:
Carbon compatibility or Eloquent query builder support remains a barrier for hybrid systems.compareTo()) may introduce overhead for high-frequency operations.Stringable interface was removed from Month, which could break user code relying on __toString() (now only available via magic method).DateTime::modify() was "fixed" (likely altered behavior), and internal refactoring may affect extensions or forks.isMidnight()/isNotMidnight() simplify time checks (e.g., for nightly batch jobs).Stringable removal: Code using Month as a string (e.g., echo $month) will fail unless using the magic __toString().modify() behavior change: May break existing logic relying on DateTime::modify() (e.g., Calendar::now()->modify('+1 day')).TimeZone class may introduce inconsistencies if not aligned with Laravel’s Carbon defaults.Stringable removal and modify() alterations require code audits.Carbon’s mutate()).compareTo()) may add overhead; benchmarking required.Month string usage and DateTime::modify() calls.Month::__toString() and DateTime::modify() in a custom class.Carbon for critical paths (e.g., event scheduling).Month objects as strings (e.g., echo $month)? If yes, how will this be mitigated?modify() behavior:
DateTime::modify() behavior, and how does the "fix" affect existing logic?spatie/calendar, carbon) be prioritized?TimeZone class conflict with Laravel’s default timezone settings?Carbon patterns may conflict with immutable design.Query Builder integration complicates ORM usage.Pilot Phase:
aeon-php/calendar.Month string usage (now requires magic __toString()).DateTime::modify() behavior.Carbon.Incremental Adoption:
DateTime with Calendar in new logic:
// config/app.php
'bindings' => [
DateTimeInterface::class => function () {
return new \Aeon\Calendar\DateTime();
},
];
class LaravelCalendar extends \Aeon\Calendar\Calendar
{
public function __toString(): string
{
return $this->format('Y-m-d H:i:s');
}
public function modify(string $modifier): self
{
// Custom logic to handle Laravel-specific modifications
return $this->add(\Aeon\Calendar\Duration::fromString($modifier));
}
}
Hybrid Approach:
Carbon’s API for gradual migration:
// CalendarServiceProvider.php
facade-root@ CalendarFacade.php
facade@ Calendar { \App\Services\LaravelCalendarWrapper }
Carbon compatibility layer (e.g., __toString() fallback, createFromFormat).Carbon for timezone consistency.intl still required for timezone support (same as Carbon).Stringable removal: Replace Month string usage with echo $month->__toString() or format methods.DateTime::modify(): Override or avoid in migration.Month string usage.DateTime::modify() calls.new DateTime() with Calendar in new logic.Carbon compatibility layer if hybrid usage is needed.Stringable removal and modify() alterations add risk.LaravelCalendar wrapper) for onboarding.Month string usage and modify().compareTo()) may require learning.Stringable removal and modify() behavior may cause runtime errors.Month string output."DateTime::modify() calls."Stringable-related failures.How can I help you explore Laravel packages today?