Boron¶
A multi-calendar, drop-in replacement for Carbon.
Boron (B) is element 5 of the periodic table. Carbon (C) is element 6. Boron sits right next to Carbon - a little lighter, and it knows more calendars.
Boron adds Jalali (Shamsi / Solar Hijri), Hijri (Islamic / Lunar), and Gregorian
calendars on top of Carbon. You keep the entire Carbon API - diffing,
localization, setTestNow(), type-hints against Carbon\Carbon - and gain a
calendar layer that converts freely between systems.
use Boron\Carbon;
Carbon::parse('2024-03-20')->toJalali(); // 1403-01-01 (Nowruz!)
Carbon::parse('2024-03-20')->toHijri(); // 1445-09-10 (Ramadan 10)
Carbon::fromJalali(1403, 5, 19)->toDateString(); // 2024-08-09
Carbon::now()->calendarFormat('l j F Y', 'jalali', 'fa', true);
// چهارشنبه ۱ فروردین ۱۴۰۳
Why Boron?¶
- Not a reinvention -
Boron\CarbonextendsCarbon\Carbon; Laravel and every Carbon type-hint keep working. - Two driver families - pure-PHP arithmetic (inspired by
date-object) and ICU via
ext-intl. - Presentation-layer calendars - the stored instant stays Gregorian; other calendars are a view for input and display.
- Laravel-ready - auto-discovered provider, Eloquent casts,
php artisan about, and Laravel Boost AI skills.
Class family¶
| Class | Extends | Role |
|---|---|---|
Boron\Carbon |
Carbon\Carbon |
Mutable drop-in |
Boron\CarbonImmutable |
Carbon\CarbonImmutable |
Immutable drop-in |
Boron\CarbonInterface |
Carbon\CarbonInterface |
Calendar-aware contract |
Next steps¶
- Install the package
- Read the quick start
- Understand the mental model
- Wire it into Laravel if you use it