diff --git a/.gitattributes b/.gitattributes index 4723185..1a31373 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,6 @@ -.coveralls.yml export-ignore +.github .gitattributes export-ignore .gitignore export-ignore -.travis.yml export-ignore Makefile export-ignore phpunit.xml.dist export-ignore tests/ export-ignore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ce665de --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +name: test + +on: +- push +- pull_request + +jobs: + phpunit: + name: phpunit + runs-on: ubuntu-18.04 + strategy: + matrix: + php-version: + - "5.6" + - "7.0" + - "7.4" + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + coverage: xdebug + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + tools: composer:v2 + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: | + ~/.composer/cache + vendor + key: "php-${{ matrix.php-version }}" + restore-keys: "php-${{ matrix.php-version }}" + + - name: Install dependencies + run: composer install --no-interaction --no-progress + + - name: Run PHPUnit + run: make test-coveralls + + - name: Upload code coverage + if: ${{ matrix.php-version == '5.6' }} + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + composer global require php-coveralls/php-coveralls + php-coveralls --coverage_clover=build/logs/clover.xml -v diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b157087..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -sudo: false - -language: php - -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - nightly - -matrix: - allow_failures: - - php: nightly - -before_script: - - if [[ $TRAVIS_PHP_VERSION != "5.6" ]]; then phpenv config-rm xdebug.ini; fi - -script: - - if [[ $TRAVIS_PHP_VERSION == "5.6" ]]; then make test-coveralls; else make test; fi diff --git a/LICENSE b/LICENSE index 9ad311f..19db9f1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ The ICanBoogie/DateTime package is free software. It is released under the terms of the following BSD License. -Copyright (c) 2013-2019 by Olivier Laviale +Copyright (c) 2013-2022 by Olivier Laviale All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -28,4 +28,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/Makefile b/Makefile index 47fd4c5..f13be6b 100644 --- a/Makefile +++ b/Makefile @@ -1,57 +1,26 @@ # customization PACKAGE_NAME = ICanBoogie/DateTime -PACKAGE_VERSION = v1.2 -PHPUNIT_VERSION = phpunit-5.7.phar -PHPUNIT_FILENAME = build/$(PHPUNIT_VERSION) -PHPUNIT = php $(PHPUNIT_FILENAME) +PHPUNIT = vendor/bin/phpunit # do not edit the following lines -all: $(PHPUNIT_FILENAME) vendor - -usage: - @echo "test: Runs the test suite.\ndoc: Creates the documentation.\nclean: Removes the documentation, the dependencies and the Composer files." - vendor: @composer install -update: - @composer update - -autoload: vendor - @composer dump-autoload - -test-dependencies: $(PHPUNIT_FILENAME) vendor - -$(PHPUNIT_FILENAME): - mkdir -p build - wget https://phar.phpunit.de/$(PHPUNIT_VERSION) -O $(PHPUNIT_FILENAME) +.PHONY: test-dependencies +test-dependencies: vendor +.PHONY: test test: test-dependencies @$(PHPUNIT) +.PHONY: test-coverage test-coverage: test-dependencies @mkdir -p build/coverage @$(PHPUNIT) --coverage-html build/coverage +.PHONY: test-coveralls test-coveralls: test-dependencies @mkdir -p build/logs - composer require --dev php-coveralls/php-coveralls @$(PHPUNIT) --coverage-clover build/logs/clover.xml - php vendor/bin/php-coveralls -v - -doc: vendor - @mkdir -p build/docs - @apigen generate \ - --source lib \ - --destination build/docs/ \ - --title "$(PACKAGE_NAME) $(PACKAGE_VERSION)" \ - --template-theme "bootstrap" - -clean: - @rm -fR build - @rm -fR vendor - @rm -f composer.lock - -.PHONY: all autoload doc clean test test-coverage test-coveralls update diff --git a/README.md b/README.md index 5fda1be..edbb488 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # DateTime [![Release](https://img.shields.io/packagist/v/ICanBoogie/DateTime.svg)](https://packagist.org/packages/icanboogie/datetime) -[![Build Status](https://img.shields.io/travis/ICanBoogie/DateTime.svg)](http://travis-ci.org/ICanBoogie/DateTime) [![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/DateTime.svg)](https://coveralls.io/r/ICanBoogie/DateTime) [![Packagist](https://img.shields.io/packagist/dm/icanboogie/datetime.svg?maxAge=2592000)](https://packagist.org/packages/icanboogie/datetime) @@ -344,16 +343,12 @@ echo $date->localize('fr')->as_medium; // 5 mai 2015 23:13:05 - - ## Requirement The package requires PHP 5.6 or later. - - ## Installation The recommended way to install this package is through [Composer](https://getcomposer.org/): @@ -368,19 +363,6 @@ If the package is not included, `RunTimeException` instances are thrown instead. - - -### Cloning the repository - -The package is [available on GitHub](https://github.com/ICanBoogie/DateTime), its repository can be -cloned with the following command line: - - $ git clone https://github.com/ICanBoogie/DateTime.git - - - - - ## Documentation The package is documented as part of the [ICanBoogie](http://icanboogie.org/) framework @@ -397,28 +379,17 @@ The following classes are documented: +## Continuous Integration +The project is continuously tested by [GitHub actions](https://github.com/ICanBoogie/DateTime/actions). -## Testing - -The test suite is ran with the `make test` command. [Composer](http://getcomposer.org/) is -automatically installed as well as all the dependencies required to run the suite. The package -directory can later be cleaned with the `make clean` command. - -The package is continuously tested by [Travis CI](http://about.travis-ci.org/). - -[![Build Status](https://travis-ci.org/ICanBoogie/DateTime.svg)](https://travis-ci.org/ICanBoogie/DateTime) -[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/DateTime.svg)](https://coveralls.io/r/ICanBoogie/DateTime) - - +[![Tests](https://github.com/ICanBoogie/DateTime/workflows/test/badge.svg?branch=master)](https://github.com/ICanBoogie/DateTime/actions?query=workflow%3Atest) ## License -**icanboogie/datetime** is licensed under the New BSD License - See the [LICENSE](LICENSE) file for details. - - +**ICanBoogie/DateTime** is released under the [BSD-3-Clause](LICENSE). diff --git a/composer.json b/composer.json index 3a2765c..136b752 100644 --- a/composer.json +++ b/composer.json @@ -3,13 +3,13 @@ "type": "library", "description": "Extends the features of PHP DateTime and DateTimeZone", "keywords": ["time", "date", "timezone"], - "homepage": "http://icanboogie.org/", + "homepage": "https://icanboogie.org/", "license": "BSD-3-Clause", "authors": [ { "name": "Olivier Laviale", "email": "olivier.laviale@gmail.com", - "homepage": "http://www.weirdog.com/", + "homepage": "https://olvlvl.com", "role" : "Developer" } ], @@ -21,7 +21,8 @@ "php": ">=5.6.0" }, "require-dev": { - "icanboogie/common": "~1.2" + "icanboogie/common": "^1.2", + "phpunit/phpunit": "^5.6" }, "suggest": { "icanboogie/common": "Allows finer exceptions to be thrown" diff --git a/lib/DateTime.php b/lib/DateTime.php index 2db7f9a..bf3d096 100644 --- a/lib/DateTime.php +++ b/lib/DateTime.php @@ -237,7 +237,7 @@ static public function from($source, $timezone = null) if ($source instanceof \DateTime) { - return new static($source->format(self::DB), $source->getTimezone()); + return new static($source->format('Y-m-d\TH:i:s.u'), $source->getTimezone()); } return new static($source, $timezone);