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