Skip to content

Commit

Permalink
Merge pull request #2 from iiifx-production/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
iiifx authored Mar 14, 2018
2 parents 97841c2 + 2e69072 commit a4d88f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@ $builder->createNumber(); # 2295209520
[link-downloads]: https://packagist.org/packages/iiifx-production/ukraine-identification-number
[link-travis]: https://travis-ci.org/iiifx-production/ukraine-identification-number
[link-scrutinizer]: https://scrutinizer-ci.com/g/iiifx-production/ukraine-identification-number/?branch=master

3 changes: 2 additions & 1 deletion source/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected function parseNumber ()
( $this->number{6} * 10 ) +
( $this->number{7} * 5 ) +
( $this->number{8} * 7 );
$daysFromBirthday = substr( $this->number, 0, 5 );
$this->controlDigit = ( $this->controlSumm % 11 ) % 10;
$this->isValid = $this->controlDigit === (int) $this->number{9};
if ( $this->isValid ) {
Expand All @@ -92,7 +93,7 @@ protected function parseNumber ()
'1900-01-01 00:00:00',
new DateTimeZone( 'UTC' )
);
$days = substr( $this->number, 0, 5 ) - 1;
$days = ((int) $daysFromBirthday > 0) ? ($daysFromBirthday - 1) : 0;
$this->birthDatetime = $datetime->modify( "+ {$days} days" );
}
}
Expand Down

0 comments on commit a4d88f8

Please sign in to comment.