Skip to content

Commit

Permalink
add hijri to jalali method
Browse files Browse the repository at this point in the history
  • Loading branch information
hanifhefaz committed Apr 10, 2023
1 parent 578af03 commit 80f30dc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Dcter.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public static function ConstructDayMonthYear($date, $format)
$format_Ar = str_split($format);
$srcDate_Ar = str_split($date);
for ($i = 0; $i < count($format_Ar); $i++) {
if (isset($srcDate_Ar[$i])) {
switch ($format_Ar[$i]) {
case "D":
self::$Day .= $srcDate_Ar[$i];
Expand All @@ -91,6 +92,7 @@ public static function ConstructDayMonthYear($date, $format)
break;
}
}
}
}
}

Expand Down Expand Up @@ -277,4 +279,21 @@ public static function Carbonize($date)
{
return Carbon::parse($date);
}

public static function HijriToJalali($date, $format = "YYYY-MM-DD")
{
$gregorianDate = self::HijriToGregorian($date);
$jalali = self::GregorianToJalali($gregorianDate);
return $jalali;
}

// This function is currently 10 days behind.

// public static function JalaliToHijri($date, $format = "YYYY-MM-DD")
// {
// $gregorianDate = self::JalaliToGregorian($date);
// $hijri = self::GregorianToHijri($gregorianDate);

// return $hijri;
// }
}

0 comments on commit 80f30dc

Please sign in to comment.