Skip to content

Commit

Permalink
carbon 3 !
Browse files Browse the repository at this point in the history
  • Loading branch information
abdumu committed Jul 7, 2024
1 parent aa18df2 commit 8d6c165
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ composer.lock
/.vscode
.phpunit.result.cache
dump.rdb
.phpunit.cache/test-results
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"jaybizzle/crawler-detect": "^1.2",
"spatie/laravel-referer": "^1.6",
"torann/geoip": "^1.0|^3.0",
"nesbot/carbon": "^2.0"
"nesbot/carbon": "^2.0|^3.0"
},
"require-dev": {
"doctrine/dbal": "^2.6|^3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Periods.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function newExpiration($period)
throw new Exception("Wrong period: `{$period}`! please update config/visits.php file.");
}

return $periodCarbon->diffInSeconds() + 1;
return intval(abs($periodCarbon->diffInSeconds())) + 1;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/PeriodsTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public function day_test()


//time until redis delete periods
$this->assertEquals(1, now()->addSeconds(visits($post)->period('day')->timeLeft())->diffInDays($time));
$this->assertEquals(1, intval(abs(now()->addSeconds(visits($post)->period('day')->timeLeft())->diffInDays($time))));

//time until redis delete periods
$this->assertEquals(1, now()->addSeconds(visits('Awssat\Visits\Tests\Post')->period('day')->timeLeft())->diffInDays($time));
$this->assertEquals(1, intval(abs(now()->addSeconds(visits('Awssat\Visits\Tests\Post')->period('day')->timeLeft())->diffInDays($time))));
}

/** @test */
Expand Down

0 comments on commit 8d6c165

Please sign in to comment.