Comments (4)
@okorneliuk thanks for using the library. Can you be more precise ? What is not working ? Do you have a precise example ?
Without examples and tests script I am afraid I can not investigate your claims.
Please add more informations in your ticket
from period.
@nyamsprod Thanks you for your response.
Example:
<?php
$period1 = Period::fromDate('2022-01-01 00:00', '2022-01-01 00:10');
echo "Period 1:\n";
echo $period1->startDate->format('Y-m-d H:i') . ' - ' . $period1->endDate->format('Y-m-d H:i') . "\n";
$period2 = Period::fromDate('2022-01-01 00:10', '2022-01-01 00:20');
echo "Period 2:\n";
echo $period2->startDate->format('Y-m-d H:i') . ' - ' . $period2->endDate->format('Y-m-d H:i') . "\n";
$sequence = new Sequence($period1, $period2);
echo "Union (expected one united period) :\n";
foreach ($sequence->unions() as $period) {
echo $period->startDate->format('Y-m-d H:i') . ' - ' . $period->endDate->format('Y-m-d H:i') . "\n";
}
echo "Gaps (expected no gaps) :\n";
foreach ($sequence->gaps() as $period) {
echo $period->startDate->format('Y-m-d H:i') . ' - ' . $period->endDate->format('Y-m-d H:i') . "\n";
}
Output:
Period 1:
2022-01-01 00:00 - 2022-01-01 00:10
Period 2:
2022-01-01 00:10 - 2022-01-01 00:20
Union (expected one united period) :
2022-01-01 00:00 - 2022-01-01 00:10
2022-01-01 00:10 - 2022-01-01 00:20
Gaps (expected no gaps) :
2022-01-01 00:10 - 2022-01-01 00:10
from period.
@okorneliuk thanks for providing more informations. It may not be what you expect but the behaviour that you are experimenting is expected behaviour and is covered by tests and explain in the documentation.
A quick way to see why you get that behaviour is to use the Gant chart capabilities of the library:
use League\Period\Chart;
use League\Period\Period;
use League\Period\Sequence;
$period1 = Period::fromDate('2022-01-01 00:00', '2022-01-01 00:10');
$period2 = Period::fromDate('2022-01-01 00:10', '2022-01-01 00:20');
$sequence = new Sequence($period1, $period2);
$dataset = new Chart\Dataset([
['period1', $period1],
['period2', $period2],
['unions', $sequence->unions()],
['gaps', $sequence->gaps()],
]);
(new Chart\GanttChart())->stroke($dataset);
Which will output something like this in your terminal
period1 [----------------------------)
period2 [----------------------------)
unions [----------------------------)[----------------------------)
gaps )[
Please refer to the documentation for a full explanation.
from period.
@nyamsprod Thank you for the explanation 🙏 Now I got it. I should use Bounds::IncludeAll
to get the behavior I expect.
from period.
Related Issues (20)
- Period::split() return Sequence HOT 1
- Is v3.x still stable and secure for PHP >=5.6 compatible environments (WP Plugins) HOT 1
- Can the lib handle periods without/ignoring year? HOT 3
- Number of (over)nights HOT 3
- Possible to determine the end of a duration in a sequence? HOT 2
- Navigation on docs page seems broken HOT 2
- Upgrade from 4.11 to 4.12 getDatePeriod returns DateTimeImmutable instead of Datepoints? HOT 2
- Quotation marks in Iso80000 range cause an exception HOT 2
- Add support for PHP8.2
- Type hinting `|Type[]` returns, when not a technical possibility HOT 2
- Calling `Sequence->get()` with an index of -1 doesn't work in 4.8+ HOT 10
- Adding the boundaryType to Period named constructors ?
- Period without end HOT 3
- Add ability to associate additional custom data to a Period HOT 12
- Create from ISO8601 string HOT 11
- Merge sequences. (Logical OR similar to subtract which is logical NOT) HOT 1
- Missing Period in Sequence intersections. HOT 5
- sequence subtraction bug HOT 1
- Merge Bakame/Period-Visualizer codebase to the Period repo 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.