Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

InvalidArgumentException: Start date must be anterior to end date. #1498

Closed
jcqtc opened this issue May 29, 2018 · 2 comments
Closed

InvalidArgumentException: Start date must be anterior to end date. #1498

jcqtc opened this issue May 29, 2018 · 2 comments

Comments

@jcqtc
Copy link

jcqtc commented May 29, 2018

Every new PR have this error during the Travis build:

1) Faker\Test\Provider\DateTimeTest::testFixedSeedWithMaximumTimestamp
InvalidArgumentException: Start date must be anterior to end date.

/home/travis/build/fzaninotto/Faker/src/Faker/Provider/DateTime.php:134
/home/travis/build/fzaninotto/Faker/src/Faker/Provider/DateTime.php:216
/home/travis/build/fzaninotto/Faker/test/Faker/Provider/DateTimeTest.php:251

I can't detail more as I really don't understand where this error come from...

Here's the class:

public static function dateTimeBetween($startDate = '-30 years', $endDate = 'now', $timezone = null)
    {
        $startTimestamp = $startDate instanceof \DateTime ? $startDate->getTimestamp() : strtotime($startDate);
        $endTimestamp = static::getMaxTimestamp($endDate);
        if ($startTimestamp > $endTimestamp) {
            throw new \InvalidArgumentException('Start date must be anterior to end date.');
        }
        $timestamp = mt_rand($startTimestamp, $endTimestamp);
        return static::setTimezone(
            new \DateTime('@' . $timestamp),
            $timezone
        );
    }
@ppelgrims
Copy link
Contributor

Fixed by #1469

@jcqtc
Copy link
Author

jcqtc commented Jun 13, 2018

@ppelgrims cool!

@jcqtc jcqtc closed this as completed Jun 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants