tizen beta release
[framework/web/web-ui-fw.git] / libs / js / globalize / generator / UmAlQuraCalendar.js
1                     _yearInfo: [
2                         // MonthLengthFlags, Gregorian Date
3                         [746, -2198707200000],
4                         [1769, -2168121600000],
5                         [3794, -2137449600000],
6                         [3748, -2106777600000],
7                         [3402, -2076192000000],
8                         [2710, -2045606400000],
9                         [1334, -2015020800000],
10                         [2741, -1984435200000],
11                         [3498, -1953763200000],
12                         [2980, -1923091200000],
13                         [2889, -1892505600000],
14                         [2707, -1861920000000],
15                         [1323, -1831334400000],
16                         [2647, -1800748800000],
17                         [1206, -1770076800000],
18                         [2741, -1739491200000],
19                         [1450, -1708819200000],
20                         [3413, -1678233600000],
21                         [3370, -1647561600000],
22                         [2646, -1616976000000],
23                         [1198, -1586390400000],
24                         [2397, -1555804800000],
25                         [748, -1525132800000],
26                         [1749, -1494547200000],
27                         [1706, -1463875200000],
28                         [1365, -1433289600000],
29                         [1195, -1402704000000],
30                         [2395, -1372118400000],
31                         [698, -1341446400000],
32                         [1397, -1310860800000],
33                         [2994, -1280188800000],
34                         [1892, -1249516800000],
35                         [1865, -1218931200000],
36                         [1621, -1188345600000],
37                         [683, -1157760000000],
38                         [1371, -1127174400000],
39                         [2778, -1096502400000],
40                         [1748, -1065830400000],
41                         [3785, -1035244800000],
42                         [3474, -1004572800000],
43                         [3365, -973987200000],
44                         [2637, -943401600000],
45                         [685, -912816000000],
46                         [1389, -882230400000],
47                         [2922, -851558400000],
48                         [2898, -820886400000],
49                         [2725, -790300800000],
50                         [2635, -759715200000],
51                         [1175, -729129600000],
52                         [2359, -698544000000],
53                         [694, -667872000000],
54                         [1397, -637286400000],
55                         [3434, -606614400000],
56                         [3410, -575942400000],
57                         [2710, -545356800000],
58                         [2349, -514771200000],
59                         [605, -484185600000],
60                         [1245, -453600000000],
61                         [2778, -422928000000],
62                         [1492, -392256000000],
63                         [3497, -361670400000],
64                         [3410, -330998400000],
65                         [2730, -300412800000],
66                         [1238, -269827200000],
67                         [2486, -239241600000],
68                         [884, -208569600000],
69                         [1897, -177984000000],
70                         [1874, -147312000000],
71                         [1701, -116726400000],
72                         [1355, -86140800000],
73                         [2731, -55555200000],
74                         [1370, -24883200000],
75                         [2773, 5702400000],
76                         [3538, 36374400000],
77                         [3492, 67046400000],
78                         [3401, 97632000000],
79                         [2709, 128217600000],
80                         [1325, 158803200000],
81                         [2653, 189388800000],
82                         [1370, 220060800000],
83                         [2773, 250646400000],
84                         [1706, 281318400000],
85                         [1685, 311904000000],
86                         [1323, 342489600000],
87                         [2647, 373075200000],
88                         [1198, 403747200000],
89                         [2422, 434332800000],
90                         [1388, 465004800000],
91                         [2901, 495590400000],
92                         [2730, 526262400000],
93                         [2645, 556848000000],
94                         [1197, 587433600000],
95                         [2397, 618019200000],
96                         [730, 648691200000],
97                         [1497, 679276800000],
98                         [3506, 709948800000],
99                         [2980, 740620800000],
100                         [2890, 771206400000],
101                         [2645, 801792000000],
102                         [693, 832377600000],
103                         [1397, 862963200000],
104                         [2922, 893635200000],
105                         [3026, 924307200000],
106                         [3012, 954979200000],
107                         [2953, 985564800000],
108                         [2709, 1016150400000],
109                         [1325, 1046736000000],
110                         [1453, 1077321600000],
111                         [2922, 1107993600000],
112                         [1748, 1138665600000],
113                         [3529, 1169251200000],
114                         [3474, 1199923200000],
115                         [2726, 1230508800000],
116                         [2390, 1261094400000],
117                         [686, 1291680000000],
118                         [1389, 1322265600000],
119                         [874, 1352937600000],
120                         [2901, 1383523200000],
121                         [2730, 1414195200000],
122                         [2381, 1444780800000],
123                         [1181, 1475366400000],
124                         [2397, 1505952000000],
125                         [698, 1536624000000],
126                         [1461, 1567209600000],
127                         [1450, 1597881600000],
128                         [3413, 1628467200000],
129                         [2714, 1659139200000],
130                         [2350, 1689724800000],
131                         [622, 1720310400000],
132                         [1373, 1750896000000],
133                         [2778, 1781568000000],
134                         [1748, 1812240000000],
135                         [1701, 1842825600000],
136                         [0, 1873411200000]
137                     ],
138                     minDate: -2198707200000,
139                     maxDate: 1873411199999,
140                     toGregorian: function(hyear, hmonth, hday) {
141                         var days = hday - 1,
142                             gyear = hyear - 1318;
143                         if (gyear < 0 || gyear >= this._yearInfo.length) return null;
144                         var info = this._yearInfo[gyear],
145                             gdate = new Date(info[1]),
146                             monthLength = info[0];
147                         // Date's ticks in javascript are always from the GMT time,
148                         // but we are interested in the gregorian date in the same timezone,
149                         // not what the gregorian date was at GMT time, so we adjust for the offset.
150                         gdate.setMinutes(gdate.getMinutes() + gdate.getTimezoneOffset());
151                         for (var i = 0; i < hmonth; i++) {
152                             days += 29 + (monthLength & 1);
153                             monthLength = monthLength >> 1;
154                         }
155                         gdate.setDate(gdate.getDate() + days);
156                         return gdate;
157                     },
158                     fromGregorian: function(gdate) {
159                         // Date's ticks in javascript are always from the GMT time,
160                         // but we are interested in the hijri date in the same timezone,
161                         // not what the hijri date was at GMT time, so we adjust for the offset.
162                         var ticks = gdate - gdate.getTimezoneOffset() * 60000;
163                         if (ticks < this.minDate || ticks > this.maxDate) return null;
164                         var hyear = 0,
165                             hmonth = 1;
166                         // find the earliest gregorian date in the array that is greater than or equal to the given date
167                         while (ticks > this._yearInfo[++hyear][1]) { }
168                         if (ticks !== this._yearInfo[hyear][1]) {
169                             hyear--;
170                         }
171                         var info = this._yearInfo[hyear],
172                             // how many days has it been since the date we found in the array?
173                             // 86400000 = ticks per day
174                             days = Math.floor((ticks - info[1]) / 86400000),
175                             monthLength = info[0];
176                         hyear += 1318; // the Nth array entry corresponds to hijri year 1318+N
177                         // now increment day/month based on the total days, considering
178                         // how many days are in each month. We cannot run past the year
179                         // mark since we would have found a different array entry in that case.
180                         var daysInMonth = 29 + (monthLength & 1);
181                         while (days >= daysInMonth) {
182                             days -= daysInMonth;
183                             monthLength = monthLength >> 1;
184                             daysInMonth = 29 + (monthLength & 1);
185                             hmonth++;
186                         }
187                         // remaining days is less than is in one month, thus is the day of the month we landed on
188                         // hmonth-1 because in javascript months are zero based, stay consistent with that.
189                         return [hyear, hmonth - 1, days + 1];
190                     }