Commit:    0826d393703fa20aea2321d19a74532f52fe7117
Author:    Stanislav Malyshev <s...@php.net>         Sun, 5 Aug 2012 20:15:21 
-0700
Parents:   dedc8f2682b14187782d9ff230529a049ffe8079
Branches:  master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=0826d393703fa20aea2321d19a74532f52fe7117

Log:
some fixes for bug#54254

Bugs:
https://bugs.php.net/54254

Changed paths:
  M  ext/calendar/calendar.c
  M  ext/calendar/jewish.c
  M  ext/calendar/sdncal.h
  M  ext/calendar/tests/jdmonthname.phpt
  M  ext/calendar/tests/jdtojewish.phpt


Diff:
diff --git a/ext/calendar/calendar.c b/ext/calendar/calendar.c
index 1ab1f16..5947aab 100644
--- a/ext/calendar/calendar.c
+++ b/ext/calendar/calendar.c
@@ -204,8 +204,8 @@ static struct cal_entry_t 
cal_conversion_table[CAL_NUM_CALS] = {
         FrenchMonthName, FrenchMonthName}
 };
 
-#define JEWISH_MONTH_NAME(year)        ((monthsPerYear[(year) % 19] == 
13)?JewishMonthNameLeap:JewishMonthName)
-#define JEWISH_HEB_MONTH_NAME(year) ((monthsPerYear[(year) % 19] == 
13)?JewishMonthHebNameLeap:JewishMonthHebName)
+#define JEWISH_MONTH_NAME(year)        ((monthsPerYear[((year)-1) % 19] == 
13)?JewishMonthNameLeap:JewishMonthName)
+#define JEWISH_HEB_MONTH_NAME(year) ((monthsPerYear[((year)-1) % 19] == 
13)?JewishMonthHebNameLeap:JewishMonthHebName)
 
 /* For jddayofweek */
 enum { CAL_DOW_DAYNO, CAL_DOW_SHORT, CAL_DOW_LONG };
diff --git a/ext/calendar/jewish.c b/ext/calendar/jewish.c
index 494d065..a5849a7 100644
--- a/ext/calendar/jewish.c
+++ b/ext/calendar/jewish.c
@@ -86,7 +86,7 @@
  *          4 Tevet     29   29   29         29   29   29
  *          5 Shevat    30   30   30         30   30   30
  *          6 Adar I    --   --   --         30   30   30 (optional)
- *          7 Adar II   29   29   29         29   29   29
+ *          7 Adar (II) 29   29   29         29   29   29
  *          8 Nisan     30   30   30         30   30   30
  *          9 Iyyar     29   29   29         29   29   29
  *         10 Sivan     30   30   30         30   30   30
@@ -286,7 +286,7 @@
 #define AM3_11_20 ((9 * HALAKIM_PER_HOUR) + 204)
 #define AM9_32_43 ((15 * HALAKIM_PER_HOUR) + 589)
 
-static int monthsPerYear[19] =
+int monthsPerYear[19] =
 {
 12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13
 };
diff --git a/ext/calendar/sdncal.h b/ext/calendar/sdncal.h
index 81328d1..c0463c8 100644
--- a/ext/calendar/sdncal.h
+++ b/ext/calendar/sdncal.h
@@ -79,7 +79,10 @@ long int JulianToSdn(int year, int month, int day);
 void SdnToJewish(long int sdn, int *pYear, int *pMonth, int *pDay);
 long int JewishToSdn(int year, int month, int day);
 extern char *JewishMonthName[14];
+extern char *JewishMonthNameLeap[14];
 extern char *JewishMonthHebName[14];
+extern char *JewishMonthHebNameLeap[14];
+extern int monthsPerYear[19];
 
 /* French republic calendar conversions. */
 void SdnToFrench(long int sdn, int *pYear, int *pMonth, int *pDay);
diff --git a/ext/calendar/tests/jdmonthname.phpt 
b/ext/calendar/tests/jdmonthname.phpt
index d05d3c5..207d320 100644
--- a/ext/calendar/tests/jdmonthname.phpt
+++ b/ext/calendar/tests/jdmonthname.phpt
@@ -178,7 +178,7 @@ Heshvan
 Kislev
 Tevet
 Shevat
-AdarI
+Adar
 Nisan
 Iyyar
 Sivan
@@ -279,7 +279,7 @@ Heshvan
 Kislev
 Tevet
 Shevat
-AdarI
+Adar
 Nisan
 Iyyar
 Sivan
diff --git a/ext/calendar/tests/jdtojewish.phpt 
b/ext/calendar/tests/jdtojewish.phpt
index 484b957..bc0ecbd 100644
--- a/ext/calendar/tests/jdtojewish.phpt
+++ b/ext/calendar/tests/jdtojewish.phpt
@@ -14,10 +14,11 @@ var_dump(jdtojewish(gregoriantojd(10,28,2002))."\r\n".
        jdtojewish(gregoriantojd(10,8,2002),true, 
CAL_JEWISH_ADD_GERESHAYIM)."\r\n".
        jdtojewish(gregoriantojd(10,8,2002),true, 
CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n".
        jdtojewish(gregoriantojd(10,8,2002),true, 
CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM)."\r\n".
-       jdtojewish(gregoriantojd(10,8,2002),true, 
CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n");
+       jdtojewish(gregoriantojd(10,8,2002),true, 
CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n".
+       jdtojewish(gregoriantojd(3,10,2007))."\r\n");
 ?>
---EXPECT--
-string(184) "2/22/5763
+--EXPECTF--
+string(%d) "2/22/5763
 �� ���� �����
 �� ���� �'����
 �� ���� � ����� ����
@@ -27,4 +28,5 @@ string(184) "2/22/5763
 �' ���� �'���"�
 �' ���� � ����� ���"�
 �' ���� �' ����� ���"�
+7/20/5767
 "


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to