From 647adae4391255f281fb62f90980e55a8c26da37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Tegn=C3=A9r?= Date: Sat, 20 Jan 2024 13:02:17 +0100 Subject: [PATCH] Added 'getDate' to documentation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Johannes Tegnér --- README.md | 19 ++++++++++--------- src/Personnummer.php | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2fe8714..fe6923d 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,15 @@ composer require personnummer/personnummer | valid | string personnummer, [ array options[*](#options) ] | bool | #### Instance -| Method | Arguments | Returns | -|----------------------|:----------------|--------:| -| format | bool longFormat | string | -| getAge | none | int | -| isMale | none | bool | -| isFemale | none | bool | -| isCoordinationNumber | none | bool | -| isInterimNumber | none | bool | +| Method | Arguments | Returns | +|----------------------|:----------------|---------:| +| format | bool longFormat | string | +| getAge | none | int | +| isMale | none | bool | +| isFemale | none | bool | +| isCoordinationNumber | none | bool | +| isInterimNumber | none | bool | +| getDate | none | DateTime | | Property | Type | Description | | ---------|:-------|----------------------------:| @@ -43,7 +44,7 @@ When a personnummer is invalid a PersonnummerException is thrown. | Option | Type | Default | Description | |-------------------------|:-----|:--------|:---------------------------:| | allowCoordinationNumber | bool | true | Accept coordination numbers | -| allowInterimNumber | bool | false | Accept interim/T numbers | +| allowInterimNumber | bool | false | Accept interim/T numbers | ## Examples diff --git a/src/Personnummer.php b/src/Personnummer.php index fe5ae96..7064848 100644 --- a/src/Personnummer.php +++ b/src/Personnummer.php @@ -148,6 +148,7 @@ private static function getParts(string $ssn): array } $parts['fullYear'] = $parts['century'] . $parts['year']; + $parts['realDay'] = $parts['day'] > 60 ? $parts['day'] - 60 : $parts['day']; $parts['original'] = $ssn; return $parts; } @@ -233,7 +234,7 @@ public function getDate(): DateTime { return DateTime::createFromFormat( 'Ymd', - $this->parts['fullYear'] .$this->parts['month'] . $this->parts['realDay'] + $this->parts['fullYear'] . $this->parts['month'] . $this->parts['realDay'] ); }