You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a first sight, this sound like a big enough project to deserve its own package.
Then any kind of package can be integrated in Carbon using macros.
With this use-case it would look like:
// This class could come from a dedicate packageclass CalendarAnalyzer
{
publicfunctionanalyze(
DateTimeImmutable$now,
string$pattern,
int$iterations = 1,
): DateTimeImmutable {
// Here comes the actual algorithm which can be completely agnostic from CarbonreturnnewDateTimeImmutable('...');
}
}
// Then when bootstrapping the app, we can turn it into a Carbon macro:
Carbon::macro('analyzeCalendar', staticfunction (string$pattern, int$iterations = 1) {
$analyzer = newCalendarAnalyzer();
return Carbon::instance($analyzer->analyze(self::this(), $pattern, $iterations));
});
// Then later in your app, you can use it right from Carbon:
Carbon::analyzeCalendar('Tue *-12-25');
Carbon::parse('2026-01-01')->analyzeCalendar('*-02-29', 3);
It would be nice to have something like
systemd-analyze calendar
in CarbonIdea: https://chaos.social/@rixx/113381352980372544
Docs: https://www.man7.org/linux/man-pages/man1/systemd-analyze.1.html#:~:text=Example%2012.%20Show%20leap%20days%20in%20the%20near%20future
The text was updated successfully, but these errors were encountered: