We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 2ebd705 + e862ea2 commit 0ff80b5Copy full SHA for 0ff80b5
1 file changed
src/Reader.php
@@ -133,9 +133,23 @@ public function getKecamatan()
133
*/
134
public function getTanggalLahir()
135
{
136
- $code = substr($this->nik, 6, 12);
+ $code = substr($this->nik, 6, 6);
137
list($day, $month, $year) = str_split($code, 2);
138
139
+ $day = (((int) $day - 40) > 0) ? ($day - 40) : $day;
140
+
141
+ $max = date('Y') - 17;
142
+ $min = 1945;
143
+ $temp = '20' . $year;
144
+ $low = '19' . $year;
145
+ $high = '20' . $year;
146
147
+ $year = ($temp > $min) ? (($high > $max) ? $low : $high) : $low;
148
149
+ if ($year < $min) {
150
+ throw new Exceptions\InvalidDateOfBirthException('Error! year: ' . $year);
151
+ }
152
153
try {
154
return DateTime::createFromFormat(
155
'd-m-Y',
0 commit comments