From: Operating system: Linux/Windows PHP version: 5.3.3 Package: Calendar related Bug Type: Feature/Change Request Bug description:Support Persian Calendar
Description: ------------ Hi, I want use Persian calendar in PHP, but not support this feature; In Iran we use none standard script for implement this feature and It is not likely...! If year%33 remaining 1, 5, 9, 13, 17, 22, 26, 30 this year will calling leap year. Persian calendar: months/abbrevmonths are: Farvardin, Ordibehesht, Khordad, Tir, Mordad, Shahrivar, Mehr, Aban, Azar, Dey, Bahman, Esfand daysname/abbrevdaysname: Yekshanbeh = Sunday, Doshanbeh, Seshhanbeh, Chaharshanbeh, Panjshanbeh, Jomeh, Shanbeh week begin from Shanbeh days range in month: 29-31 I use below script: http://www.fourmilab.ch/documents/calendar/ Thanks for cooperation. Regards Test script: --------------- const CAL_PERSIAN = 4; const PERSIAN_EPOCH = 1948320.5; function Persian2JD($year, $month, $day) { $epbase = $year - (($year >= 0) ? 474 : 473); $epyear = 474 + $epbase%2820; return $day + (($month <= 7) ? (($month - 1) * 31) : ((($month - 1) * 30) + 6)) + (int)((($epyear * 682) - 110) / 2816) + ($epyear - 1) * 365 + (int)($epbase / 2820) * 1029983 + (PERSIAN_EPOCH - 1); } function JD2Persian($jd) { # Calculate Persian date from Julian day $jd = (int)$jd + 0.5; $depoch = $jd - Persian2JD(475, 1, 1); $cycle = (int)($depoch / 1029983); $cyear = $depoch%1029983; if ($cyear == 1029982) $ycycle = 2820; else { $aux1 = (int)($cyear / 366); $aux2 = $cyear%366; $ycycle = (int)(((2134 * $aux1) + (2816 * $aux2) + 2815) / 1028522) + $aux1 + 1; } $year = $ycycle + (2820 * $cycle) + 474; if ($year <= 0) $year--; $yday = ($jd - Persian2JD($year, 1, 1)) + 1; $month = ($yday <= 186) ? ceil($yday / 31) : ceil(($yday - 6) / 30); $day = ($jd - Persian2JD($year, $month, 1)) + 1; return $year.'-'.str_pad($month, 2, 0, STR_PAD_LEFT).'-'.str_pad($day, 2, 0, STR_PAD_LEFT); } -- Edit bug report at http://bugs.php.net/bug.php?id=52972&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52972&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52972&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52972&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52972&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52972&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52972&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52972&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52972&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52972&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52972&r=support Expected behavior: http://bugs.php.net/fix.php?id=52972&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52972&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52972&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52972&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52972&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52972&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52972&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52972&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52972&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52972&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52972&r=mysqlcfg