1
0
mirror of https://github.com/fzaninotto/Faker.git synced 2025-04-19 23:12:01 +02:00

Fix dateTimeThisYear method (#2039)

This commit is contained in:
macaron 2020-10-23 16:19:26 +09:00 committed by GitHub
parent 74f8b2ec6b
commit 2f538cc46c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -202,7 +202,7 @@ class DateTime extends Base
*/
public static function dateTimeThisYear($max = 'now', $timezone = null)
{
return static::dateTimeBetween('-1 year', $max, $timezone);
return static::dateTimeBetween('first day of january this year', $max, $timezone);
}
/**

View File

@ -122,7 +122,7 @@ final class DateTimeTest extends TestCase
{
$date = DateTimeProvider::dateTimeThisYear();
$this->assertInstanceOf('\DateTime', $date);
$this->assertGreaterThanOrEqual(new \DateTime('-1 year'), $date);
$this->assertGreaterThanOrEqual(new \DateTime('first day of january this year'), $date);
$this->assertLessThanOrEqual(new \DateTime(), $date);
$this->assertEquals(new \DateTimeZone($this->defaultTz), $date->getTimezone());
}