| @@ 300-336 (lines=37) @@ | ||
| 297 | } |
|
| 298 | ||
| 299 | break; |
|
| 300 | case 'week': |
|
| 301 | $nbOccurencesToCreate = $game->getOccurrenceNumber() - $nbExistingOccurrences; |
|
| 302 | $nbWeeksInterval = (int) ($dateInterval/(60*24*7)); |
|
| 303 | // If a week don't last 7d, I consider it as a week anyway. |
|
| 304 | if ($dateInterval%(60*24*7) > 0) { |
|
| 305 | ++$nbWeeksInterval; |
|
| 306 | } |
|
| 307 | $beginningDrawDate = \DateTime::createFromFormat( |
|
| 308 | 'm/d/Y H:i:s', |
|
| 309 | $beginning->format('m/d/Y'). ' 00:00:00' |
|
| 310 | ); |
|
| 311 | $endDrawDate = \DateTime::createFromFormat( |
|
| 312 | 'm/d/Y H:i:s', |
|
| 313 | $beginning->format('m/d/Y'). ' 23:59:59' |
|
| 314 | ); |
|
| 315 | $endDrawDate->add(new \DateInterval('P6D')); |
|
| 316 | if ($endDrawDate > $end) { |
|
| 317 | $endDrawDate = $end; |
|
| 318 | } |
|
| 319 | ||
| 320 | if ($nbOccurencesToCreate > 0) { |
|
| 321 | for ($d=1; $d<=$nbWeeksInterval; $d++) { |
|
| 322 | $this->createRandomOccurrences( |
|
| 323 | $game, |
|
| 324 | $beginningDrawDate, |
|
| 325 | $endDrawDate, |
|
| 326 | $nbOccurencesToCreate |
|
| 327 | ); |
|
| 328 | $beginningDrawDate->add(new \DateInterval('P1W')); |
|
| 329 | $endDrawDate->add(new \DateInterval('P1W')); |
|
| 330 | if ($endDrawDate > $end) { |
|
| 331 | $endDrawDate = $end; |
|
| 332 | } |
|
| 333 | } |
|
| 334 | } |
|
| 335 | ||
| 336 | break; |
|
| 337 | case 'month': |
|
| 338 | $nbOccurencesToCreate = $game->getOccurrenceNumber() - $nbExistingOccurrences; |
|
| 339 | $nbMonthsInterval = (int) ($dateInterval/(60*24*30)); |
|
| @@ 337-371 (lines=35) @@ | ||
| 334 | } |
|
| 335 | ||
| 336 | break; |
|
| 337 | case 'month': |
|
| 338 | $nbOccurencesToCreate = $game->getOccurrenceNumber() - $nbExistingOccurrences; |
|
| 339 | $nbMonthsInterval = (int) ($dateInterval/(60*24*30)); |
|
| 340 | // If a week don't last 30d, I consider it as a month anyway. |
|
| 341 | if ($dateInterval%(60*24*30) > 0) { |
|
| 342 | ++$nbMonthsInterval; |
|
| 343 | } |
|
| 344 | $beginningDrawDate = \DateTime::createFromFormat( |
|
| 345 | 'm/d/Y H:i:s', |
|
| 346 | $beginning->format('m/d/Y'). ' 00:00:00' |
|
| 347 | ); |
|
| 348 | $endDrawDate = \DateTime::createFromFormat('m/d/Y H:i:s', $beginning->format('m/d/Y'). ' 23:59:59'); |
|
| 349 | $endDrawDate->add(new \DateInterval('P1M')); |
|
| 350 | $endDrawDate->sub(new \DateInterval('P1D')); |
|
| 351 | if ($endDrawDate > $end) { |
|
| 352 | $endDrawDate = $end; |
|
| 353 | } |
|
| 354 | ||
| 355 | if ($nbOccurencesToCreate > 0) { |
|
| 356 | for ($d=1; $d<=$nbMonthsInterval; $d++) { |
|
| 357 | $this->createRandomOccurrences( |
|
| 358 | $game, |
|
| 359 | $beginningDrawDate, |
|
| 360 | $endDrawDate, |
|
| 361 | $nbOccurencesToCreate |
|
| 362 | ); |
|
| 363 | $beginningDrawDate->add(new \DateInterval('P1M')); |
|
| 364 | $endDrawDate->add(new \DateInterval('P1M')); |
|
| 365 | if ($endDrawDate > $end) { |
|
| 366 | $endDrawDate = $end; |
|
| 367 | } |
|
| 368 | } |
|
| 369 | } |
|
| 370 | ||
| 371 | break; |
|
| 372 | } |
|
| 373 | ||
| 374 | return true; |
|