| @@ 385-421 (lines=37) @@ | ||
| 382 | } |
|
| 383 | ||
| 384 | break; |
|
| 385 | case 'week': |
|
| 386 | $nbOccurencesToCreate = $game->getOccurrenceNumber() - $nbExistingOccurrences; |
|
| 387 | $nbWeeksInterval = (int) ($dateInterval/(60*24*7)); |
|
| 388 | // If a week don't last 7d, I consider it as a week anyway. |
|
| 389 | if ($dateInterval%(60*24*7) > 0) { |
|
| 390 | ++$nbWeeksInterval; |
|
| 391 | } |
|
| 392 | $beginningDrawDate = \DateTime::createFromFormat( |
|
| 393 | 'm/d/Y H:i:s', |
|
| 394 | $beginning->format('m/d/Y'). ' 00:00:00' |
|
| 395 | ); |
|
| 396 | $endDrawDate = \DateTime::createFromFormat( |
|
| 397 | 'm/d/Y H:i:s', |
|
| 398 | $beginning->format('m/d/Y'). ' 23:59:59' |
|
| 399 | ); |
|
| 400 | $endDrawDate->add(new \DateInterval('P6D')); |
|
| 401 | if ($endDrawDate > $end) { |
|
| 402 | $endDrawDate = $end; |
|
| 403 | } |
|
| 404 | ||
| 405 | if ($nbOccurencesToCreate > 0) { |
|
| 406 | for ($d=1; $d<=$nbWeeksInterval; $d++) { |
|
| 407 | $this->createRandomOccurrences( |
|
| 408 | $game, |
|
| 409 | $beginningDrawDate, |
|
| 410 | $endDrawDate, |
|
| 411 | $nbOccurencesToCreate |
|
| 412 | ); |
|
| 413 | $beginningDrawDate->add(new \DateInterval('P1W')); |
|
| 414 | $endDrawDate->add(new \DateInterval('P1W')); |
|
| 415 | if ($endDrawDate > $end) { |
|
| 416 | $endDrawDate = $end; |
|
| 417 | } |
|
| 418 | } |
|
| 419 | } |
|
| 420 | ||
| 421 | break; |
|
| 422 | case 'month': |
|
| 423 | $nbOccurencesToCreate = $game->getOccurrenceNumber() - $nbExistingOccurrences; |
|
| 424 | $nbMonthsInterval = (int) ($dateInterval/(60*24*30)); |
|
| @@ 422-456 (lines=35) @@ | ||
| 419 | } |
|
| 420 | ||
| 421 | break; |
|
| 422 | case 'month': |
|
| 423 | $nbOccurencesToCreate = $game->getOccurrenceNumber() - $nbExistingOccurrences; |
|
| 424 | $nbMonthsInterval = (int) ($dateInterval/(60*24*30)); |
|
| 425 | // If a week don't last 30d, I consider it as a month anyway. |
|
| 426 | if ($dateInterval%(60*24*30) > 0) { |
|
| 427 | ++$nbMonthsInterval; |
|
| 428 | } |
|
| 429 | $beginningDrawDate = \DateTime::createFromFormat( |
|
| 430 | 'm/d/Y H:i:s', |
|
| 431 | $beginning->format('m/d/Y'). ' 00:00:00' |
|
| 432 | ); |
|
| 433 | $endDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y'). ' 23:59:59'); |
|
| 434 | $endDrawDate->add(new \DateInterval('P1M')); |
|
| 435 | $endDrawDate->sub(new \DateInterval('P1D')); |
|
| 436 | if ($endDrawDate > $end) { |
|
| 437 | $endDrawDate = $end; |
|
| 438 | } |
|
| 439 | ||
| 440 | if ($nbOccurencesToCreate > 0) { |
|
| 441 | for ($d=1; $d<=$nbMonthsInterval; $d++) { |
|
| 442 | $this->createRandomOccurrences( |
|
| 443 | $game, |
|
| 444 | $beginningDrawDate, |
|
| 445 | $endDrawDate, |
|
| 446 | $nbOccurencesToCreate |
|
| 447 | ); |
|
| 448 | $beginningDrawDate->add(new \DateInterval('P1M')); |
|
| 449 | $endDrawDate->add(new \DateInterval('P1M')); |
|
| 450 | if ($endDrawDate > $end) { |
|
| 451 | $endDrawDate = $end; |
|
| 452 | } |
|
| 453 | } |
|
| 454 | } |
|
| 455 | ||
| 456 | break; |
|
| 457 | } |
|
| 458 | ||
| 459 | return true; |
|