-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PHP 8.1 compatibility * update github action to run tests for php 8.1 * Force the version of CS Fixer * Update PHPUnit before running tests
- Loading branch information
1 parent
a2e8df0
commit 64d4bd8
Showing
17 changed files
with
408 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! -f ./php-cs-fixer ]; then | ||
wget https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer | ||
wget https://cs.symfony.com/download/v3.4.0/php-cs-fixer.phar -O php-cs-fixer | ||
chmod +x php-cs-fixer | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace frictionlessdata\tableschema\Utility; | ||
|
||
final class StrptimeFormatTransformer | ||
{ | ||
public static function transform(string $strptimeFormat): string | ||
{ | ||
return strtr( | ||
$strptimeFormat, | ||
[ | ||
// Day | ||
'%d' => 'd', // 09 | ||
'%e' => 'j', // 9 | ||
|
||
// Month | ||
'%m' => 'm', // 02 | ||
'%b' => 'M', // Feb | ||
'%B' => 'F', // February | ||
|
||
// Year | ||
'%Y' => 'Y', // 2023 | ||
'%y' => 'y', // 23 | ||
|
||
// Hour | ||
'%H' => 'H', // 00 to 23 | ||
'%k' => 'G', // 0 to 23 | ||
'%I' => 'h', // 00 to 12 | ||
'%l' => 'h', // 0 to 12 | ||
'%p' => 'A', // AM / PM | ||
'%P' => 'a', // am / pm | ||
|
||
// Minute | ||
'%M' => 'i', | ||
|
||
// Second | ||
'%S' => 's', | ||
|
||
// Date | ||
'%D' => 'm/d/y', | ||
'%F' => 'Y-m-d', | ||
|
||
// Time | ||
'%r' => 'h:i:s A', | ||
'%R' => 'H:i', | ||
'%T' => 'H:i:s', | ||
'%s' => 'U', | ||
] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace frictionlessdata\tableschema\tests\Fields; | ||
|
||
use Carbon\Carbon; | ||
use DateTime; | ||
use DateTimeInterface; | ||
use frictionlessdata\tableschema\Fields\DateField; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \frictionlessdata\tableschema\Fields\DateField | ||
*/ | ||
class DateFieldTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider provideDateFormatTestData | ||
*/ | ||
public function testParseDateFormat(DateTimeInterface $expectedDateTime, string $format, $dateValue): void | ||
{ | ||
$descriptor = (object) ['format' => $format]; | ||
$sut = new DateField($descriptor); | ||
|
||
$castValue = $sut->castValue($dateValue); | ||
self::assertInstanceOf(Carbon::class, $castValue); | ||
|
||
self::assertTrue( | ||
$castValue->eq($expectedDateTime) | ||
); | ||
} | ||
|
||
public static function provideDateFormatTestData(): iterable | ||
{ | ||
yield [new DateTime('2023-02-28'), '%Y-%m-%d', '2023-02-28']; | ||
} | ||
} |
Oops, something went wrong.