Comments (2)
That's not possible yet, since the underlying iterator only supports days, not arbitrary precisions. Feel free to submit a tested PR if you want this functionality to be supported.
from period.
I had the same issue and I resolved it with a splitter utility that makes use of Carbon\CarbonPeriod
.
<?php
declare(strict_types=1);
namespace App\Service;
use Carbon\CarbonInterface;
use Carbon\CarbonPeriod;
use Spatie\Period\PeriodCollection;
final class SlotSplitter
{
private PeriodCollection $slots;
public function __construct(PeriodCollection $slots)
{
$this->slots = $slots;
}
/** @return array<int, CarbonInterface|null> */
public function split(int $minutes): array
{
$splitPeriods = [];
$interval = sprintf('%d minutes', $minutes);
foreach ($this->slots as $item) {
$carbonPeriod = CarbonPeriod::create($item->start(), $interval, $item->end());
$carbonPeriod->excludeEndDate();
foreach ($carbonPeriod as $period) {
$splitPeriods[$period->timestamp] = $period;
}
}
ksort($splitPeriods);
return $splitPeriods;
}
}
from period.
Related Issues (20)
- Improve PHP 8.1.0 support... HOT 1
- Hours, minutes and seconds are reset from provided period HOT 1
- ISO-8601 time interval support
- Overlap percentage
- Add periods to a PeriodCollection? HOT 1
- Created a PeriodCollection, tried ->overlapAll() but it returns the same collection of periods, not overlaps
- Precision::fromString incompatible to Boundaries::fromString HOT 2
- Exception thrown when getting gaps for a 0-length period with excluded boundaries HOT 3
- Visualizer cause error when it have one period HOT 1
- Support for Eloquent
- Period roundDate() does not keep date's timezone HOT 1
- Carry over exclusion HOT 3
- Why does diff sometimes return a gap? HOT 1
- Is the package really still a work in progress ? HOT 1
- Precision - Overlap by X minutes HOT 3
- Documentation typo HOT 1
- Visualization bugs HOT 1
- Is this package suitable for appointment systems?
- Grab properties of Period object HOT 1
- Check if Period overlaps any Period's within a PeriodCollection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from period.