Answer the question
In order to leave comments, you need to log in
Subtraction of periods, how to implement?
Good day!
I have a question and I don't know how to solve it.
Let's say we have three periods.
# Где
$period->getDate()->getFirstDate() //2017-11-06T00:00:00
# и соответственно
$period->getDate()->getLastDate() //2017-11-20T00:00:00
# если статус false, то его надо вычитать.
$period->getDate()->getStatus() //2017-11-20T00:00:00
Answer the question
In order to leave comments, you need to log in
Subtraction (A - B) is reduced to four options:
1. A->firstDate >= B->firstDate && A->lastDate <= B->lastDate Period
A is completely removed.
2. A->firstDate > B->firstDate && A->lastDate > B->lastDate
A->firstDate := B->lastDate
3. A->firstDate < B->firstDate && A->lastDate < B->lastDate
A->lastDate := B-> firstBade
4. A->firstDate < B->firstDate && A->lastDate > B->lastDate
Period A is replaced by two new ones:
A1->firstDate := A->firstDate, A1->lastDate := B->firstDate
A2->firstDate := B->lastDate, A2->lastDate := A->lastDate
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question