OLD | NEW |
1 /* | 1 /* |
2 ****************************************************************************** | 2 ****************************************************************************** |
3 * Copyright (C) 2003-2013, International Business Machines Corporation | 3 * Copyright (C) 2003-2014, International Business Machines Corporation |
4 * and others. All Rights Reserved. | 4 * and others. All Rights Reserved. |
5 ****************************************************************************** | 5 ****************************************************************************** |
6 * | 6 * |
7 * File ISLAMCAL.H | 7 * File ISLAMCAL.H |
8 * | 8 * |
9 * Modification History: | 9 * Modification History: |
10 * | 10 * |
11 * Date Name Description | 11 * Date Name Description |
12 * 10/14/2003 srl ported from java IslamicCalendar | 12 * 10/14/2003 srl ported from java IslamicCalendar |
13 ***************************************************************************** | 13 ***************************************************************************** |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 U_CDECL_END | 71 U_CDECL_END |
72 | 72 |
73 U_NAMESPACE_BEGIN | 73 U_NAMESPACE_BEGIN |
74 | 74 |
75 // Implementation of the IslamicCalendar class | 75 // Implementation of the IslamicCalendar class |
76 | 76 |
77 /** | 77 /** |
78 * Friday EPOC | 78 * Friday EPOC |
79 */ | 79 */ |
80 static const int32_t CIVIL_EPOC = 1948440; | 80 static const int32_t CIVIL_EPOC = 1948440; // CE 622 July 16 Friday (Julian cale
ndar) / CE 622 July 19 (Gregorian calendar) |
81 | 81 |
82 /** | 82 /** |
83 * Thursday EPOC | 83 * Thursday EPOC |
84 */ | 84 */ |
85 static const int32_t ASTRONOMICAL_EPOC = 1948439; | 85 static const int32_t ASTRONOMICAL_EPOC = 1948439; // CE 622 July 15 Thursday (Ju
lian calendar) |
86 | 86 |
87 | 87 |
88 static const int32_t UMALQURA_YEAR_START = 1318; | 88 static const int32_t UMALQURA_YEAR_START = 1300; |
89 static const int32_t UMALQURA_YEAR_END = 1480; | 89 static const int32_t UMALQURA_YEAR_END = 1600; |
90 | 90 |
91 static const int UMALQURA_MONTHLENGTH[] = { | 91 static const int UMALQURA_MONTHLENGTH[] = { |
92 //* 1318 -1322 */ "0101 0111 0100", "1001 0111 0110", "0100 1011 0111", "001
0 0101 0111", "0101 0010 1011", | 92 //* 1300 -1302 */ "1010 1010 1010", "1101 0101 0100", "1110 1100 1001", |
93 0x0574, 0x0975, 0x06A7,
0x0257, 0x052B, | 93 0x0AAA, 0x0D54, 0x0EC9, |
94 //* 1323 -1327 */ "0110 1001 0101", "0110 1100 1010", "1010 1101 0101", "010
1 0101 1011", "0010 0101 1101", | 94 //* 1303 -1307 */ "0110 1101 0100", "0110 1110 1010", "0011 0110 1100", "101
0 1010 1101", "0101 0101 0101", |
95 0x0695, 0x06CA, 0x0AD5,
0x055B, 0x025B, | 95 0x06D4, 0x06EA, 0x036C,
0x0AAD, 0x0555, |
96 //* 1328 -1332 */ "1001 0010 1101", "1100 1001 0101", "1101 0100 1010", "111
0 1010 0101", "0110 1101 0010", | 96 //* 1308 -1312 */ "0110 1010 1001", "0111 1001 0010", "1011 1010 1001", "010
1 1101 0100", "1010 1101 1010", |
97 0x092D, 0x0C95, 0x0D4A,
0x0E5B, 0x025B, | 97 0x06A9, 0x0792, 0x0BA9,
0x05D4, 0x0ADA, |
98 //* 1333 -1337 */ "1010 1101 0101", "0101 0101 1010", "1010 1010 1011", "010
0 0100 1011", "0110 1010 0101", | 98 //* 1313 -1317 */ "0101 0101 1100", "1101 0010 1101", "0110 1001 0101", "011
1 0100 1010", "1011 0101 0100", |
99 0x0AD5, 0x055A, 0x0AAB,
0x044B, 0x06A5, | 99 0x055C, 0x0D2D, 0x0695,
0x074A, 0x0B54, |
100 //* 1338 -1342 */ "0111 0101 0010", "1011 1010 1001", "0011 0111 0100", "101
0 1011 0110", "0101 0101 0110", | 100 //* 1318 -1322 */ "1011 0110 1010", "0101 1010 1101", "0100 1010 1110", "101
0 0100 1111", "0101 0001 0111", |
101 0x0752, 0x0BA9, 0x0374,
0x0AB6, 0x0556, | 101 0x0B6A, 0x05AD, 0x04AE,
0x0A4F, 0x0517, |
102 //* 1343 -1347 */ "1010 1010 1010", "1101 0101 0010", "1101 1010 1001", "010
1 1101 0100", "1010 1110 1010", | 102 //* 1323 -1327 */ "0110 1000 1011", "0110 1010 0101", "1010 1101 0101", "001
0 1101 0110", "1001 0101 1011", |
103 0x0AAA, 0x0D52, 0x0DA9,
0x05D4, 0x0AEA, | 103 0x068B, 0x06A5, 0x0AD5,
0x02D6, 0x095B, |
104 //* 1348 -1352 */ "0100 1101 1101", "0010 0110 1110", "1001 0010 1110", "101
0 1010 0110", "1101 0101 0100", | 104 //* 1328 -1332 */ "0100 1001 1101", "1010 0100 1101", "1101 0010 0110", "110
1 1001 0101", "0101 1010 1100", |
105 0x04DD, 0x026E, 0x092E,
0x0AA6, 0x0D54, | 105 0x049D, 0x0A4D, 0x0D26,
0x0D95, 0x05AC, |
106 //* 1353 -1357 */ "0101 1010 1010", "0101 1011 0101", "0010 1011 0100", "100
1 0011 0111", "0100 1001 1011", | 106 //* 1333 -1337 */ "1001 1011 0110", "0010 1011 1010", "1010 0101 1011", "010
1 0010 1011", "1010 1001 0101", |
107 0x05AA, 0x05B5, 0x02B4,
0x0937, 0x049B, | 107 0x09B6, 0x02BA, 0x0A5B,
0x052B, 0x0A95, |
108 //* 1358 -1362 */ "1010 0100 1011", "1011 0010 0101", "1011 0101 0100", "101
1 0110 1010", "0101 0110 1101", | 108 //* 1338 -1342 */ "0110 1100 1010", "1010 1110 1001", "0010 1111 0100", "100
1 0111 0110", "0010 1011 0110", |
109 0x0A4B, 0x0B25, 0x0B54,
0x0B6A, 0x056D, | 109 0x06CA, 0x0AE9, 0x02F4,
0x0976, 0x02B6, |
110 //* 1363 -1367 */ "0100 1010 1101", "1010 0101 0101", "1101 0010 0101", "111
0 1001 0010", "1110 1100 1001", | 110 //* 1343 -1347 */ "1001 0101 0110", "1010 1100 1010", "1011 1010 0100", "101
1 1101 0010", "0101 1101 1001", |
111 0x04AD, 0x0A55, 0x0D25,
0x0E92, 0x0EC9, | 111 0x0956, 0x0ACA, 0x0BA4,
0x0BD2, 0x05D9, |
112 //* 1368 -1372 */ "0110 1101 0100", "1010 1110 1010", "0101 0110 1011", "010
0 1010 1011", "0110 1000 0101", | 112 //* 1348 -1352 */ "0010 1101 1100", "1001 0110 1101", "0101 0100 1101", "101
0 1010 0101", "1011 0101 0010", |
113 0x06D4, 0x0ADA, 0x056B,
0x04AB, 0x0685, | 113 0x02DC, 0x096D, 0x054D,
0x0AA5, 0x0B52, |
114 //* 1373 -1377 */ "1011 0100 1001", "1011 1010 0100", "1011 1011 0010", "010
1 1011 0101", "0010 1011 1010", | 114 //* 1353 -1357 */ "1011 1010 0101", "0101 1011 0100", "1001 1011 0110", "010
1 0101 0111", "0010 1001 0111", |
115 0x0B49, 0x0BA4, 0x0BB2,
0x05B5, 0x02BA, | 115 0x0BA5, 0x05B4, 0x09B6,
0x0557, 0x0297, |
116 //* 1378 -1382 */ "1001 0101 1011", "0100 1010 1011", "0101 0101 0101", "011
0 1011 0010", "0110 1101 1001", | 116 //* 1358 -1362 */ "0101 0100 1011", "0110 1010 0011", "0111 0101 0010", "101
1 0110 0101", "0101 0110 1010", |
117 0x095B, 0x04AB, 0x0555,
0x06B2, 0x06D9, | 117 0x054B, 0x06A3, 0x0752,
0x0B65, 0x056A, |
118 //* 1383 -1387 */ "0010 1110 1100", "1001 0110 1110", "0100 1010 1110", "101
0 0101 0110", "1101 0010 1010", | 118 //* 1363 -1367 */ "1010 1010 1011", "0101 0010 1011", "1100 1001 0101", "110
1 0100 1010", "1101 1010 0101", |
119 0x02EC, 0x096E, 0x04AE,
0x0A56, 0x0D2A, | 119 0x0AAB, 0x052B, 0x0C95,
0x0D4A, 0x0DA5, |
120 //* 1388 -1392 */ "1101 0101 0101", "0101 1010 1010", "1010 1011 0101", "010
0 1011 1011", "0000 0101 1011", | 120 //* 1368 -1372 */ "0101 1100 1010", "1010 1101 0110", "1001 0101 0111", "010
0 1010 1011", "1001 0100 1011", |
121 0x0D55, 0x05AA, 0x0AB5,
0x04BB, 0x005B, | 121 0x05CA, 0x0AD6, 0x0957,
0x04AB, 0x094B, |
122 //* 1393 -1397 */ "1001 0010 1011", "1010 1001 0101", "0011 0100 1010", "101
1 1010 0101", "0101 1010 1010", | 122 //* 1373 -1377 */ "1010 1010 0101", "1011 0101 0010", "1011 0110 1010", "010
1 0111 0101", "0010 0111 0110", |
123 0x092B, 0x0A95, 0x034A,
0x0BA5, 0x05AA, | 123 0x0AA5, 0x0B52, 0x0B6A,
0x0575, 0x0276, |
124 //* 1398 -1402 */ "1010 1011 0101", "0101 0101 0110", "1010 1001 0110", "110
1 0100 1010", "1110 1010 0101", | 124 //* 1378 -1382 */ "1000 1011 0111", "0100 0101 1011", "0101 0101 0101", "010
1 1010 1001", "0101 1011 0100", |
125 0x0AB5, 0x0556, 0x0A96,
0x0B4A, 0x0EA5, | 125 0x08B7, 0x045B, 0x0555,
0x05A9, 0x05B4, |
126 //* 1403 -1407 */ "0111 0101 0010", "0110 1110 1001", "0011 0110 1010", "101
0 1010 1101", "0101 0101 0101", | 126 //* 1383 -1387 */ "1001 1101 1010", "0100 1101 1101", "0010 0110 1110", "100
1 0011 0110", "1010 1010 1010", |
127 0x0752, 0x06E9, 0x036A,
0x0AAD, 0x0555, | 127 0x09DA, 0x04DD, 0x026E,
0x0936, 0x0AAA, |
128 //* 1408 -1412 */ "1010 1010 0101", "1011 0101 0010", "1011 1010 1001", "010
1 1011 0100", "1001 1011 1010", | 128 //* 1388 -1392 */ "1101 0101 0100", "1101 1011 0010", "0101 1101 0101", "001
0 1101 1010", "1001 0101 1011", |
129 0x0AA5, 0x0B52, 0x0BA9,
0x05B4, 0x09BA, | 129 0x0D54, 0x0DB2, 0x05D5,
0x02DA, 0x095B, |
130 //* 1413 -1417 */ "0100 1101 1011", "0010 0101 1101", "0101 0010 1101", "101
0 1010 0101", "1010 1101 0100", | 130 //* 1393 -1397 */ "0100 1010 1011", "1010 0101 0101", "1011 0100 1001", "101
1 0110 0100", "1011 0111 0001", |
131 0x04DB, 0x025D, 0x052D,
0x0AA5, 0x0AD4, | 131 0x04AB, 0x0A55, 0x0B49,
0x0B64, 0x0B71, |
132 //* 1418 -1422 */ "1010 1110 1010", "0101 0110 1101", "0100 1011 1101", "001
0 0011 1101", "1001 0001 1101", | 132 //* 1398 -1402 */ "0101 1011 0100", "1010 1011 0101", "1010 0101 0101", "110
1 0010 0101", "1110 1001 0010", |
133 0x0AEA, 0x056D, 0x04BD,
0x023D, 0x091D, | 133 0x05B4, 0x0AB5, 0x0A55,
0x0D25, 0x0E92, |
| 134 //* 1403 -1407 */ "1110 1100 1001", "0110 1101 0100", "1010 1110 1001", "100
1 0110 1011", "0100 1010 1011", |
| 135 0x0EC9, 0x06D4, 0x0AE9,
0x096B, 0x04AB, |
| 136 //* 1408 -1412 */ "1010 1001 0011", "1101 0100 1001", "1101 1010 0100", "110
1 1011 0010", "1010 1011 1001", |
| 137 0x0A93, 0x0D49, 0x0DA4,
0x0DB2, 0x0AB9, |
| 138 //* 1413 -1417 */ "0100 1011 1010", "1010 0101 1011", "0101 0010 1011", "101
0 1001 0101", "1011 0010 1010", |
| 139 0x04BA, 0x0A5B, 0x052B,
0x0A95, 0x0B2A, |
| 140 //* 1418 -1422 */ "1011 0101 0101", "0101 0101 1100", "0100 1011 1101", "001
0 0011 1101", "1001 0001 1101", |
| 141 0x0B55, 0x055C, 0x04BD,
0x023D, 0x091D, |
134 //* 1423 -1427 */ "1010 1001 0101", "1011 0100 1010", "1011 0101 1010", "010
1 0110 1101", "0010 1011 0110", | 142 //* 1423 -1427 */ "1010 1001 0101", "1011 0100 1010", "1011 0101 1010", "010
1 0110 1101", "0010 1011 0110", |
135 0x0A95, 0x0B4A, 0x0B5A,
0x056D, 0x02B6, | 143 0x0A95, 0x0B4A, 0x0B5A,
0x056D, 0x02B6, |
136 //* 1428 -1432 */ "1001 0011 1011", "0100 1001 1011", "0110 0101 0101", "011
0 1010 1001", "0111 0101 0100", | 144 //* 1428 -1432 */ "1001 0011 1011", "0100 1001 1011", "0110 0101 0101", "011
0 1010 1001", "0111 0101 0100", |
137 0x093B, 0x049B, 0x0655,
0x06A9, 0x0754, | 145 0x093B, 0x049B, 0x0655,
0x06A9, 0x0754, |
138 //* 1433 -1437 */ "1011 0110 1010", "0101 0110 1100", "1010 1010 1101", "010
1 0101 0101", "1011 0010 1001", | 146 //* 1433 -1437 */ "1011 0110 1010", "0101 0110 1100", "1010 1010 1101", "010
1 0101 0101", "1011 0010 1001", |
139 0x0B6A, 0x056C, 0x0AAD,
0x0555, 0x0B29, | 147 0x0B6A, 0x056C, 0x0AAD,
0x0555, 0x0B29, |
140 //* 1438 -1442 */ "1011 1001 0010", "1011 1010 1001", "0101 1101 0100", "101
0 1101 1010", "0101 0101 1010", | 148 //* 1438 -1442 */ "1011 1001 0010", "1011 1010 1001", "0101 1101 0100", "101
0 1101 1010", "0101 0101 1010", |
141 0x0B92, 0x0BA9, 0x05D4,
0x0ADA, 0x055A, | 149 0x0B92, 0x0BA9, 0x05D4,
0x0ADA, 0x055A, |
142 //* 1443 -1447 */ "1010 1010 1011", "0101 1001 0101", "0111 0100 1001", "011
1 0110 0100", "1011 1010 1010", | 150 //* 1443 -1447 */ "1010 1010 1011", "0101 1001 0101", "0111 0100 1001", "011
1 0110 0100", "1011 1010 1010", |
143 0x0AAB, 0x0595, 0x0749,
0x0764, 0x0BAA, | 151 0x0AAB, 0x0595, 0x0749,
0x0764, 0x0BAA, |
144 //* 1448 -1452 */ "0101 1011 0101", "0010 1011 0110", "1010 0101 0110", "111
0 0100 1101", "1011 0010 0101", | 152 //* 1448 -1452 */ "0101 1011 0101", "0010 1011 0110", "1010 0101 0110", "111
0 0100 1101", "1011 0010 0101", |
145 0x05B5, 0x02B6, 0x0A56,
0x0E4D, 0x0B25, | 153 0x05B5, 0x02B6, 0x0A56,
0x0E4D, 0x0B25, |
146 //* 1453 -1457 */ "1011 0101 0010", "1011 0110 1010", "0101 1010 1101", "001
0 1010 1110", "1001 0010 1111", | 154 //* 1453 -1457 */ "1011 0101 0010", "1011 0110 1010", "0101 1010 1101", "001
0 1010 1110", "1001 0010 1111", |
147 0x0B52, 0x0B6A, 0x05AD,
0x02AE, 0x092F, | 155 0x0B52, 0x0B6A, 0x05AD,
0x02AE, 0x092F, |
148 //* 1458 -1462 */ "0100 1001 0111", "0110 0100 1011", "0110 1010 0101", "011
0 1010 1100", "1010 1101 0110", | 156 //* 1458 -1462 */ "0100 1001 0111", "0110 0100 1011", "0110 1010 0101", "011
0 1010 1100", "1010 1101 0110", |
149 0x0497, 0x064B, 0x06A5,
0x06AC, 0x0AD6, | 157 0x0497, 0x064B, 0x06A5,
0x06AC, 0x0AD6, |
150 //* 1463 -1467 */ "0101 0101 1101", "0100 1001 1101", "1010 0100 1101", "110
1 0001 0110", "1101 1001 0101", | 158 //* 1463 -1467 */ "0101 0101 1101", "0100 1001 1101", "1010 0100 1101", "110
1 0001 0110", "1101 1001 0101", |
151 0x055D, 0x049D, 0x0A4D,
0x0D16, 0x0D95, | 159 0x055D, 0x049D, 0x0A4D,
0x0D16, 0x0D95, |
152 //* 1468 -1472 */ "0101 1010 1010", "0101 1011 0101", "0010 1001 1010", "100
1 0101 1011", "0100 1010 1100", | 160 //* 1468 -1472 */ "0101 1010 1010", "0101 1011 0101", "0010 1101 1010", "100
1 0101 1011", "0100 1010 1101", |
153 0x05AA, 0x05B5, 0x029A,
0x095B, 0x04AC, | 161 0x05AA, 0x05B5, 0x02DA,
0x095B, 0x04AD, |
154 //* 1473 -1477 */ "0101 1001 0101", "0110 1100 1010", "0110 1110 0100", "101
0 1110 1010", "0100 1111 0101", | 162 //* 1473 -1477 */ "0101 1001 0101", "0110 1100 1010", "0110 1110 0100", "101
0 1110 1010", "0100 1111 0101", |
155 0x0595, 0x06CA, 0x06E4,
0x0AEA, 0x04F5, | 163 0x0595, 0x06CA, 0x06E4,
0x0AEA, 0x04F5, |
156 //* 1478 -1480 */ "0010 1011 0110", "1001 0101 0110", "1010 1010 1010" | 164 //* 1478 -1482 */ "0010 1011 0110", "1001 0101 0110", "1010 1010 1010", "101
1 0101 0100", "1011 1101 0010", |
157 0x02B6, 0x0956, 0x0AAA | 165 0x02B6, 0x0956, 0x0AAA,
0x0B54, 0x0BD2, |
| 166 //* 1483 -1487 */ "0101 1101 1001", "0010 1110 1010", "1001 0110 1101", "010
0 1010 1101", "1010 1001 0101", |
| 167 0x05D9, 0x02EA, 0x096D,
0x04AD, 0x0A95, |
| 168 //* 1488 -1492 */ "1011 0100 1010", "1011 1010 0101", "0101 1011 0010", "100
1 1011 0101", "0100 1101 0110", |
| 169 0x0B4A, 0x0BA5, 0x05B2,
0x09B5, 0x04D6, |
| 170 //* 1493 -1497 */ "1010 1001 0111", "0101 0100 0111", "0110 1001 0011", "011
1 0100 1001", "1011 0101 0101", |
| 171 0x0A97, 0x0547, 0x0693,
0x0749, 0x0B55, |
| 172 //* 1498 -1508 */ "0101 0110 1010", "1010 0110 1011", "0101 0010 1011", "101
0 1000 1011", "1101 0100 0110", "1101 1010 0011", "0101 1100 1010", "1010 1101 0
110", "0100 1101 1011", "0010 0110 1011", "1001 0100 1011", |
| 173 0x056A, 0x0A6B, 0x052B,
0x0A8B, 0x0D46, 0x0DA3, 0x05CA, 0x0AD6
, 0x04DB, 0x026B, 0x094B, |
| 174 //* 1509 -1519 */ "1010 1010 0101", "1011 0101 0010", "1011 0110 1001", "010
1 0111 0101", "0001 0111 0110", "1000 1011 0111", "0010 0101 1011", "0101 0010 1
011", "0101 0110 0101", "0101 1011 0100", "1001 1101 1010", |
| 175 0x0AA5, 0x0B52, 0x0B69,
0x0575, 0x0176, 0x08B7, 0x025B, 0x052B
, 0x0565, 0x05B4, 0x09DA, |
| 176 //* 1520 -1530 */ "0100 1110 1101", "0001 0110 1101", "1000 1011 0110", "101
0 1010 0110", "1101 0101 0010", "1101 1010 1001", "0101 1101 0100", "1010 1101 1
010", "1001 0101 1011", "0100 1010 1011", "0110 0101 0011", |
| 177 0x04ED, 0x016D, 0x08B6,
0x0AA6, 0x0D52, 0x0DA9, 0x05D4, 0x0ADA
, 0x095B, 0x04AB, 0x0653, |
| 178 //* 1531 -1541 */ "0111 0010 1001", "0111 0110 0010", "1011 1010 1001", "010
1 1011 0010", "1010 1011 0101", "0101 0101 0101", "1011 0010 0101", "1101 1001 0
010", "1110 1100 1001", "0110 1101 0010", "1010 1110 1001", |
| 179 0x0729, 0x0762, 0x0BA9,
0x05B2, 0x0AB5, 0x0555, 0x0B25, 0x0D92
, 0x0EC9, 0x06D2, 0x0AE9, |
| 180 //* 1542 -1552 */ "0101 0110 1011", "0100 1010 1011", "1010 0101 0101", "110
1 0010 1001", "1101 0101 0100", "1101 1010 1010", "1001 1011 0101", "0100 1011 1
010", "1010 0011 1011", "0100 1001 1011", "1010 0100 1101", |
| 181 0x056B, 0x04AB, 0x0A55,
0x0D29, 0x0D54, 0x0DAA, 0x09B5, 0x04BA
, 0x0A3B, 0x049B, 0x0A4D, |
| 182 //* 1553 -1563 */ "1010 1010 1010", "1010 1101 0101", "0010 1101 1010", "100
1 0101 1101", "0100 0101 1110", "1010 0010 1110", "1100 1001 1010", "1101 0101 0
101", "0110 1011 0010", "0110 1011 1001", "0100 1011 1010", |
| 183 0x0AAA, 0x0AD5, 0x02DA,
0x095D, 0x045E, 0x0A2E, 0x0C9A, 0x0D55
, 0x06B2, 0x06B9, 0x04BA, |
| 184 //* 1564 -1574 */ "1010 0101 1101", "0101 0010 1101", "1010 1001 0101", "101
1 0101 0010", "1011 1010 1000", "1011 1011 0100", "0101 1011 1001", "0010 1101 1
010", "1001 0101 1010", "1011 0100 1010", "1101 1010 0100", |
| 185 0x0A5D, 0x052D, 0x0A95,
0x0B52, 0x0BA8, 0x0BB4, 0x05B9, 0x02DA
, 0x095A, 0x0B4A, 0x0DA4, |
| 186 //* 1575 -1585 */ "1110 1101 0001", "0110 1110 1000", "1011 0110 1010", "010
1 0110 1101", "0101 0011 0101", "0110 1001 0101", "1101 0100 1010", "1101 1010 1
000", "1101 1101 0100", "0110 1101 1010", "0101 0101 1011", |
| 187 0x0ED1, 0x06E8, 0x0B6A,
0x056D, 0x0535, 0x0695, 0x0D4A, 0x0DA8
, 0x0DD4, 0x06DA, 0x055B, |
| 188 //* 1586 -1596 */ "0010 1001 1101", "0110 0010 1011", "1011 0001 0101", "101
1 0100 1010", "1011 1001 0101", "0101 1010 1010", "1010 1010 1110", "1001 0010 1
110", "1100 1000 1111", "0101 0010 0111", "0110 1001 0101", |
| 189 0x029D, 0x062B, 0x0B15,
0x0B4A, 0x0B95, 0x05AA, 0x0AAE, 0x092E
, 0x0C8F, 0x0527, 0x0695, |
| 190 //* 1597 -1600 */ "0110 1010 1010", "1010 1101 0110", "0101 0101 1101", "001
0 1001 1101", }; |
| 191 0x06AA, 0x0AD6, 0x055D,
0x029D |
158 }; | 192 }; |
159 | 193 |
160 int32_t getUmalqura_MonthLength(int32_t y, int32_t m) { | 194 int32_t getUmalqura_MonthLength(int32_t y, int32_t m) { |
161 int32_t mask = (int32_t) (0x01 << (11 - m)); // set mask for bit correspo
nding to month | 195 int32_t mask = (int32_t) (0x01 << (11 - m)); // set mask for bit correspo
nding to month |
162 if((UMALQURA_MONTHLENGTH[y] & mask) == 0 ) | 196 if((UMALQURA_MONTHLENGTH[y] & mask) == 0 ) |
163 return 29; | 197 return 29; |
164 else | 198 else |
165 return 30; | 199 return 30; |
166 | 200 |
167 } | 201 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 { | 325 { |
292 return (14 + 11 * year) % 30 < 11; | 326 return (14 + 11 * year) % 30 < 11; |
293 } | 327 } |
294 | 328 |
295 /** | 329 /** |
296 * Return the day # on which the given year starts. Days are counted | 330 * Return the day # on which the given year starts. Days are counted |
297 * from the Hijri epoch, origin 0. | 331 * from the Hijri epoch, origin 0. |
298 */ | 332 */ |
299 int32_t IslamicCalendar::yearStart(int32_t year) const{ | 333 int32_t IslamicCalendar::yearStart(int32_t year) const{ |
300 if (cType == CIVIL || cType == TBLA || | 334 if (cType == CIVIL || cType == TBLA || |
301 (cType == UMALQURA && year < UMALQURA_YEAR_START)) | 335 (cType == UMALQURA && (year < UMALQURA_YEAR_START || year > UMALQURA_YEA
R_END))) |
302 { | 336 { |
303 return (year-1)*354 + ClockMath::floorDivide((3+11*year),30); | 337 return (year-1)*354 + ClockMath::floorDivide((3+11*year),30); |
304 } else if(cType==ASTRONOMICAL){ | 338 } else if(cType==ASTRONOMICAL){ |
305 return trueMonthStart(12*(year-1)); | 339 return trueMonthStart(12*(year-1)); |
306 } else { | 340 } else { |
307 int32_t ys = yearStart(UMALQURA_YEAR_START-1); | 341 int32_t ys = yearStart(UMALQURA_YEAR_START-1); |
308 ys+= handleGetYearLength(UMALQURA_YEAR_START-1); | 342 ys+= handleGetYearLength(UMALQURA_YEAR_START-1); |
309 for(int i=UMALQURA_YEAR_START; i< year; i++){ | 343 for(int i=UMALQURA_YEAR_START; i< year; i++){ |
310 ys+= handleGetYearLength(i); | 344 ys+= handleGetYearLength(i); |
311 } | 345 } |
312 return ys; | 346 return ys; |
313 } | 347 } |
314 } | 348 } |
315 | 349 |
316 /** | 350 /** |
317 * Return the day # on which the given month starts. Days are counted | 351 * Return the day # on which the given month starts. Days are counted |
318 * from the Hijri epoch, origin 0. | 352 * from the Hijri epoch, origin 0. |
319 * | 353 * |
320 * @param year The hijri year | 354 * @param year The hijri year |
321 * @param year The hijri month, 0-based | 355 * @param year The hijri month, 0-based (assumed to be in range 0..11) |
322 */ | 356 */ |
323 int32_t IslamicCalendar::monthStart(int32_t year, int32_t month) const { | 357 int32_t IslamicCalendar::monthStart(int32_t year, int32_t month) const { |
324 if (cType == CIVIL || cType == TBLA) { | 358 if (cType == CIVIL || cType == TBLA) { |
| 359 // This does not handle months out of the range 0..11 |
325 return (int32_t)uprv_ceil(29.5*month) | 360 return (int32_t)uprv_ceil(29.5*month) |
326 + (year-1)*354 + (int32_t)ClockMath::floorDivide((3+11*year),30); | 361 + (year-1)*354 + (int32_t)ClockMath::floorDivide((3+11*year),30); |
327 } else if(cType==ASTRONOMICAL){ | 362 } else if(cType==ASTRONOMICAL){ |
328 return trueMonthStart(12*(year-1) + month); | 363 return trueMonthStart(12*(year-1) + month); |
329 } else { | 364 } else { |
330 int32_t ms = yearStart(year); | 365 int32_t ms = yearStart(year); |
331 for(int i=0; i< month; i++){ | 366 for(int i=0; i< month; i++){ |
332 ms+= handleGetMonthLength(year, i); | 367 ms+= handleGetMonthLength(year, i); |
333 } | 368 } |
334 return ms; | 369 return ms; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 */ | 495 */ |
461 int32_t IslamicCalendar::handleGetYearLength(int32_t extendedYear) const { | 496 int32_t IslamicCalendar::handleGetYearLength(int32_t extendedYear) const { |
462 if (cType == CIVIL || cType == TBLA || | 497 if (cType == CIVIL || cType == TBLA || |
463 (cType == UMALQURA && (extendedYear<UMALQURA_YEAR_START || extendedYear>
UMALQURA_YEAR_END)) ) { | 498 (cType == UMALQURA && (extendedYear<UMALQURA_YEAR_START || extendedYear>
UMALQURA_YEAR_END)) ) { |
464 return 354 + (civilLeapYear(extendedYear) ? 1 : 0); | 499 return 354 + (civilLeapYear(extendedYear) ? 1 : 0); |
465 } else if(cType == ASTRONOMICAL){ | 500 } else if(cType == ASTRONOMICAL){ |
466 int32_t month = 12*(extendedYear-1); | 501 int32_t month = 12*(extendedYear-1); |
467 return (trueMonthStart(month + 12) - trueMonthStart(month)); | 502 return (trueMonthStart(month + 12) - trueMonthStart(month)); |
468 } else { | 503 } else { |
469 int len = 0; | 504 int len = 0; |
470 for(int i=0; i<12; i++) | 505 for(int i=0; i<12; i++) { |
471 len += handleGetMonthLength(extendedYear, i); | 506 len += handleGetMonthLength(extendedYear, i); |
| 507 } |
472 return len; | 508 return len; |
473 } | 509 } |
474 } | 510 } |
475 | 511 |
476 //------------------------------------------------------------------------- | 512 //------------------------------------------------------------------------- |
477 // Functions for converting from field values to milliseconds.... | 513 // Functions for converting from field values to milliseconds.... |
478 //------------------------------------------------------------------------- | 514 //------------------------------------------------------------------------- |
479 | 515 |
480 // Return JD of start of given month/year | 516 // Return JD of start of given month/year |
| 517 // Calendar says: |
| 518 // Get the Julian day of the day BEFORE the start of this year. |
| 519 // If useMonth is true, get the day before the start of the month. |
| 520 // Hence the -1 |
481 /** | 521 /** |
482 * @draft ICU 2.4 | 522 * @draft ICU 2.4 |
483 */ | 523 */ |
484 int32_t IslamicCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U
Bool /* useMonth */) const { | 524 int32_t IslamicCalendar::handleComputeMonthStart(int32_t eyear, int32_t month, U
Bool /* useMonth */) const { |
485 return monthStart(eyear, month) + 1948439; | 525 // This may be called by Calendar::handleComputeJulianDay with months out of
the range |
| 526 // 0..11. Need to handle that here since monthStart requires months in the r
ange 0.11. |
| 527 if (month > 11) { |
| 528 eyear += (month / 12); |
| 529 month %= 12; |
| 530 } else if (month < 0) { |
| 531 month++; |
| 532 eyear += (month / 12) - 1; |
| 533 month = (month % 12) + 11; |
| 534 } |
| 535 return monthStart(eyear, month) + ((cType == TBLA)? ASTRONOMICAL_EPOC: CIVIL
_EPOC) - 1; |
486 } | 536 } |
487 | 537 |
488 //------------------------------------------------------------------------- | 538 //------------------------------------------------------------------------- |
489 // Functions for converting from milliseconds to field values | 539 // Functions for converting from milliseconds to field values |
490 //------------------------------------------------------------------------- | 540 //------------------------------------------------------------------------- |
491 | 541 |
492 /** | 542 /** |
493 * @draft ICU 2.4 | 543 * @draft ICU 2.4 |
494 */ | 544 */ |
495 int32_t IslamicCalendar::handleGetExtendedYear() { | 545 int32_t IslamicCalendar::handleGetExtendedYear() { |
(...skipping 17 matching lines...) Expand all Loading... |
513 * <li>DAY_OF_YEAR | 563 * <li>DAY_OF_YEAR |
514 * <li>EXTENDED_YEAR</ul> | 564 * <li>EXTENDED_YEAR</ul> |
515 * | 565 * |
516 * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this | 566 * The DAY_OF_WEEK and DOW_LOCAL fields are already set when this |
517 * method is called. The getGregorianXxx() methods return Gregorian | 567 * method is called. The getGregorianXxx() methods return Gregorian |
518 * calendar equivalents for the given Julian day. | 568 * calendar equivalents for the given Julian day. |
519 * @draft ICU 2.4 | 569 * @draft ICU 2.4 |
520 */ | 570 */ |
521 void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status)
{ | 571 void IslamicCalendar::handleComputeFields(int32_t julianDay, UErrorCode &status)
{ |
522 int32_t year, month, dayOfMonth, dayOfYear; | 572 int32_t year, month, dayOfMonth, dayOfYear; |
523 UDate startDate; | 573 int32_t startDate; |
524 int32_t days = julianDay - CIVIL_EPOC; | 574 int32_t days = julianDay - CIVIL_EPOC; |
525 | 575 |
526 if (cType == CIVIL || cType == TBLA) { | 576 if (cType == CIVIL || cType == TBLA) { |
527 if(cType == TBLA) | 577 if(cType == TBLA) { |
528 days = julianDay - ASTRONOMICAL_EPOC; | 578 days = julianDay - ASTRONOMICAL_EPOC; |
| 579 } |
529 // Use the civil calendar approximation, which is just arithmetic | 580 // Use the civil calendar approximation, which is just arithmetic |
530 year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631
.0 ); | 581 year = (int)ClockMath::floorDivide( (double)(30 * days + 10646) , 10631
.0 ); |
531 month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 ); | 582 month = (int32_t)uprv_ceil((days - 29 - yearStart(year)) / 29.5 ); |
532 month = month<11?month:11; | 583 month = month<11?month:11; |
533 startDate = monthStart(year, month); | 584 startDate = monthStart(year, month); |
534 } else if(cType == ASTRONOMICAL){ | 585 } else if(cType == ASTRONOMICAL){ |
535 // Guess at the number of elapsed full months since the epoch | 586 // Guess at the number of elapsed full months since the epoch |
536 int32_t months = (int32_t)uprv_floor((double)days / CalendarAstronomer::
SYNODIC_MONTH); | 587 int32_t months = (int32_t)uprv_floor((double)days / CalendarAstronomer::
SYNODIC_MONTH); |
537 | 588 |
538 startDate = uprv_floor(months * CalendarAstronomer::SYNODIC_MONTH); | 589 startDate = (int32_t)uprv_floor(months * CalendarAstronomer::SYNODIC_MON
TH); |
539 | 590 |
540 double age = moonAge(internalGetTime(), status); | 591 double age = moonAge(internalGetTime(), status); |
541 if (U_FAILURE(status)) { | 592 if (U_FAILURE(status)) { |
542 status = U_MEMORY_ALLOCATION_ERROR; | 593 status = U_MEMORY_ALLOCATION_ERROR; |
543 return; | 594 return; |
544 } | 595 } |
545 if ( days - startDate >= 25 && age > 0) { | 596 if ( days - startDate >= 25 && age > 0) { |
546 // If we're near the end of the month, assume next month and search
backwards | 597 // If we're near the end of the month, assume next month and search
backwards |
547 months++; | 598 months++; |
548 } | 599 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 month = m; | 639 month = m; |
589 } | 640 } |
590 } else { // invalid 'civil' | 641 } else { // invalid 'civil' |
591 U_ASSERT(false); // should not get here, out of range | 642 U_ASSERT(false); // should not get here, out of range |
592 year=month=0; | 643 year=month=0; |
593 } | 644 } |
594 | 645 |
595 dayOfMonth = (days - monthStart(year, month)) + 1; | 646 dayOfMonth = (days - monthStart(year, month)) + 1; |
596 | 647 |
597 // Now figure out the day of the year. | 648 // Now figure out the day of the year. |
598 dayOfYear = (days - monthStart(year, 0) + 1); | 649 dayOfYear = (days - monthStart(year, 0)) + 1; |
599 | 650 |
600 | 651 |
601 internalSet(UCAL_ERA, 0); | 652 internalSet(UCAL_ERA, 0); |
602 internalSet(UCAL_YEAR, year); | 653 internalSet(UCAL_YEAR, year); |
603 internalSet(UCAL_EXTENDED_YEAR, year); | 654 internalSet(UCAL_EXTENDED_YEAR, year); |
604 internalSet(UCAL_MONTH, month); | 655 internalSet(UCAL_MONTH, month); |
605 internalSet(UCAL_DAY_OF_MONTH, dayOfMonth); | 656 internalSet(UCAL_DAY_OF_MONTH, dayOfMonth); |
606 internalSet(UCAL_DAY_OF_YEAR, dayOfYear); | 657 internalSet(UCAL_DAY_OF_YEAR, dayOfYear); |
607 } | 658 } |
608 | 659 |
609 UBool | 660 UBool |
610 IslamicCalendar::inDaylightTime(UErrorCode& status) const | 661 IslamicCalendar::inDaylightTime(UErrorCode& status) const |
611 { | 662 { |
612 // copied from GregorianCalendar | 663 // copied from GregorianCalendar |
613 if (U_FAILURE(status) || (&(getTimeZone()) == NULL && !getTimeZone().useDayl
ightTime())) | 664 if (U_FAILURE(status) || !getTimeZone().useDaylightTime()) |
614 return FALSE; | 665 return FALSE; |
615 | 666 |
616 // Force an update of the state of the Calendar. | 667 // Force an update of the state of the Calendar. |
617 ((IslamicCalendar*)this)->complete(status); // cast away const | 668 ((IslamicCalendar*)this)->complete(status); // cast away const |
618 | 669 |
619 return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FAL
SE); | 670 return (UBool)(U_SUCCESS(status) ? (internalGet(UCAL_DST_OFFSET) != 0) : FAL
SE); |
620 } | 671 } |
621 | 672 |
622 /** | 673 /** |
623 * The system maintains a static default century start date and Year. They are | 674 * The system maintains a static default century start date and Year. They are |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 } | 720 } |
670 | 721 |
671 | 722 |
672 | 723 |
673 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IslamicCalendar) | 724 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(IslamicCalendar) |
674 | 725 |
675 U_NAMESPACE_END | 726 U_NAMESPACE_END |
676 | 727 |
677 #endif | 728 #endif |
678 | 729 |
OLD | NEW |