spatie/opening-hours
spatie/opening-hours lets you define business opening hours as a weekly schedule plus exceptions, then query whether you’re open or closed on a day or specific date and present times per day. It also works with Carbon via cmixin/business-time.
Time::isSameOrBefore()Time::isBefore() and Time::isAfter() comparing metadata and date context instead of clock time onlyisAlwaysClosed and isAlwaysOpen when opening hours contain exceptionsnextClose() result with overflow overnightgetData() with readonly property ->dataTime::date() methodDateTimeRange classto or - separatorfill() and setData()setFilters()isOpenOn() to take date string as parameterTime::diff() methodsOpeningHours::createAndMergeOverlappingRanges() and
OpeningHours::mergeOverlappingRanges()InvalidTimezone exceptionforWeekConsecutiveDays() methodpreviousOpen()previousClose()currentOpenRange()currentOpenRangeStart()currentOpenRangeEnd()TimeRange::format()asStructuredData()24:0024:00 when Time::fromString('24:00') is casted to stringMaximumLimitExceeded exception to prevent infinite loop⚠ TimeRange no longer return true on containsTime for times overflowing next day. Overflow is now calculated at the day level (OpeningHoursForDay).
OpeningHoursForDay::isOpenAtNight()TimeRange::overflowsNextDay()'overflow' => true option in array definitionsetData() and getData()TimeRange::fromArray() and TimeRange::fromDefinition() (to support array of hours+data or string[] or string)setFilters() and getFilters()⚠ Breaking changes:
nextOpen() and nextClose() return type changed for DateTimeInterface as it can now return DateTimeImmutable tootoDateTime() changed both input type and return type for DateTimeInterface as it can now take and return DateTimeImmutable toonextCloseTimeDateTime instance to mutate to Time::toDateTimeOpeningHours::forWeekCombined()regularClosingDays, regularClosingDaysISO and exceptionalClosingDates methodsasStructuredData to retrieve the opening hours as a Schema.org structured data arraynextOpen method to determine the next time the business will be openOpeningHours::map, OpeningHours::flatMap, OpeningHours::mapExceptions, OpeningHours::flatMapExceptions,OpeningHoursForDay::map and OpeningHoursForDay::emptyisClosedOn fixTime classDateTime by DateTimeInterfaceHow can I help you explore Laravel packages today?