1
0
forked from s421507/eOSP2
eOSP2/app/Common/Helpers.php
2020-07-11 20:56:21 +02:00

63 lines
2.0 KiB
PHP

<?php
namespace App\Common;
class Helpers
{
public static function peselBirthdayDate($pesel){
$pesel = (String) $pesel;
$output = $pesel[2];
$output = (int)$output;
if( $output == 0 || $output == 1){
$year = '19'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 2 || $output == 3){
$year = '20'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 4 || $output == 5){
$year = '21'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 6 || $output == 7){
$year = '22'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 8 || $output == 9){
$year = '18'."".(String)$pesel[0]."".(String)$pesel[1];
}
if($output % 2 == 0 ){
$month = '0'."".(String)$pesel[3];
}else{
$month = '1'."".(String)$pesel[3];
}
$day = (String)$pesel[4]."".(String)$pesel[5];
return $day.".".$month.".".$year;
}
public static function peselBirthdayDateARRAY($pesel){
$pesel = (String) $pesel;
$output = $pesel[2];
$output = (int)$output;
if( $output == 0 || $output == 1){
$year = '19'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 2 || $output == 3){
$year = '20'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 4 || $output == 5){
$year = '21'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 6 || $output == 7){
$year = '22'."".(String)$pesel[0]."".(String)$pesel[1];
}elseif( $output == 8 || $output == 9){
$year = '18'."".(String)$pesel[0]."".(String)$pesel[1];
}
if($output % 2 == 0 ){
$month = '0'."".(String)$pesel[3];
}else{
$month = '1'."".(String)$pesel[3];
}
$day = (String)$pesel[4]."".(String)$pesel[5];
return array($day, $month, $year);
}
}