Releases: phpnomad/chronos-integration
1.0.0
Initial release. Chronos-backed implementation of the phpnomad/chrono catalog. The default comprehensive integration: roughly a fifth the install footprint of nesbot/carbon with effectively the same surface, using ext-intl for locale-aware formatting instead of bundled translation files.
What's in the box
ChronosChronoStrategy — a single concrete that implements 28 chrono interfaces against cakephp/chronos, with IntlDateFormatter providing the locale-aware formatting Chronos 3.x dropped.
Clock
ClockStrategy
Predicates
CanCheckIfPast,CanCheckIfFuture,CanCheckIfWeekend,CanCheckIfWeekdayCanCheckSameDay,CanCheckSameMonth,CanCheckSameYear,CanCheckBetween
Arithmetic
CanApplyModifier,CanAddInterval,CanSubtractInterval
Calendar boundaries
CanGetStartOfDay,CanGetEndOfDay,CanGetStartOfMonth,CanGetEndOfMonth,CanGetStartOfYear,CanGetEndOfYear
Difference
CanGetDifference,CanGetDifferenceInDays,CanGetDifferenceInHours,CanGetDifferenceInMinutes,CanGetDifferenceInSeconds
Parsing and formatting
CanParseDate,CanParseDateWithFormatCanFormatDate,CanFormatLocalizedDate,CanFormatRelativeTime
Configuration
The strategy takes HasTimezone and HasLocale constructor dependencies — both resolved by the DI container from whichever paired integration provides them. Pair with phpnomad/wordpress-integration 4.1.0+ for WordPress-backed timezone and locale, or supply your own concretes.
public function __construct(
HasTimezone \$timezone,
HasLocale \$locale,
)Behavior notes
- Format syntax differs across methods.
format()takes PHP's nativedate()syntax.formatLocalized()takes ICU pattern syntax viaIntlDateFormatter— see the ICU patterns reference for the grammar. relative()is English-only. Chronos 3.x ships a deliberately English-onlydiffForHumanstranslator. The injected locale is ignored by this method (documented in the strategy and tested). Apps needing locale-aware relative-time strings should pair withphpnomad/wordpress-integrationorphpnomad/carbon-integration.isBetweenis inclusive on both bounds.apply()uses nativeDateTimeImmutable::modify(); PHP's default month-overflow behavior applies.parseFormat()throwsInvalidArgumentExceptionon unparseable input.diffIn*methods are signed.- Chronos's
setTestNow()is honored bynow()and therefore by every predicate.
Requirements
PHP 8.2 or newer. ext-intl. phpnomad/chrono ^1.0, cakephp/chronos ^2.4 || ^3.0.
Tests
39 tests, 77 assertions covering interface membership, the deliberate non-implementation of HasTimezone/HasLocale, clock and timezone resolution via injected providers, every predicate, arithmetic, calendar boundaries, signed diff methods, flexible and strict parsing, native and ICU-locale-aware formatting, and the documented English-only behavior of relative(). Two locale-aware format tests skip gracefully when ext-intl is unavailable.