diff --git a/src/Dcter.php b/src/Dcter.php index 9320ad3..8cffd43 100644 --- a/src/Dcter.php +++ b/src/Dcter.php @@ -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]; @@ -91,6 +92,7 @@ public static function ConstructDayMonthYear($date, $format) break; } } + } } } @@ -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; + // } } \ No newline at end of file