Skip to content

Commit

Permalink
support carbon v3 (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreyrose authored Feb 2, 2024
1 parent e0f6021 commit 31ae1fa
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,22 +403,16 @@ $ XDEBUG_MODE=coverage ./vendor/bin/phpunit

----

Test against Carbon v1
```
$ ./tests/carbon-1.sh
```

Test against Carbon v2
```
$ ./tests/carbon-2.sh
```

Test Both Carbon v1 and v2
Test against Carbon v3
```
$ ./tests/carbon-1-2.sh
$ ./tests/carbon-3.sh
```


### See It Used in the Wild
[GBPN](https://gbpn.com/resources/branding-and-design/us-holiday-calendar) - Ongoing US Holiday Calendar
[Canny Armadillo](https://cannyarmadillo.com/resources/us-holiday-calendar) - Next 12 Months
13 changes: 13 additions & 0 deletions Tests/carbon-3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

cp composer.json original-composer.json
rm composer.lock

rm -rf vendor
composer remove nesbot/carbon
composer require nesbot/carbon:3.* --no-plugins

rm composer.json
mv original-composer.json composer.json

./vendor/bin/phpunit
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"keywords": ["Bank Holiday", "Holiday", "Holidays", "Carbon", "US Holiday", "US Holidays"],
"license": "MIT",
"require": {
"nesbot/carbon": "^1.22|^2.24.0",
"php": "^7.1 || ^8.0",
"nesbot/carbon": "^2.24.0|^3.0",
"php": "^7.4 || ^8.0",
"ext-calendar": "*"
},
"autoload": {
Expand All @@ -19,7 +19,7 @@
}
},
"require-dev": {
"phpunit/phpunit": "^5|^6|^7.5|^8.0|^9.0",
"phpunit/phpunit": "^5|^6|^7.5|^8.0|^9.0|^10.0",
"php-coveralls/php-coveralls": "^2.5"
},
"config": {
Expand Down
49 changes: 21 additions & 28 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="./build/logs/clover.xml"/>
<html outputDirectory="./reports/"/>
</report>
</coverage>
<testsuites>
<testsuite name="Carbon Holidays Test Suite">
<directory>Tests</directory>
</testsuite>
</testsuites>
<logging/>
<php>
<env name="APP_ENV" value="testing"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<report>
<clover outputFile="./build/logs/clover.xml"/>
<html outputDirectory="./reports/"/>
</report>
</coverage>
<testsuites>
<testsuite name="Carbon Holidays Test Suite">
<directory>Tests</directory>
</testsuite>
</testsuites>
<logging/>
<php>
<env name="APP_ENV" value="testing"/>
</php>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/USHolidays/Carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function getHolidaysByYear($name='all', int $year=null): array
$date = call_user_func($holidays[$index]['date']);
$this->year = $currentYear;

$days_until = $this->diffInDays($date);
$days_until = abs($this->diffInDays($date));

$bankHoliday = $holidays[$index]['bank_holiday'];
// if($bankHoliday && $bankHolidayCheck) {
Expand Down Expand Up @@ -162,7 +162,7 @@ public function getHolidaysByYear($name='all', int $year=null): array
$date = call_user_func($holidays[$index]['date']);
$this->year = $currentYear;

$days_until = $this->diffInDays($date);
$days_until = abs($this->diffInDays($date));

$bankHoliday = $holidays[$index]['bank_holiday'];

Expand Down

0 comments on commit 31ae1fa

Please sign in to comment.