isite 2024.6.7 → 2024.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +1387 -1387
  3. package/apps/charts/site_files/html/PieChart.html +35 -35
  4. package/apps/charts/site_files/html/PieChart2.html +35 -35
  5. package/apps/charts/site_files/html/XYChart.html +42 -42
  6. package/apps/charts/site_files/html/column.html +60 -60
  7. package/apps/charts/site_files/html/gauge.html +44 -44
  8. package/apps/charts/site_files/html/index.html +92 -92
  9. package/apps/charts/site_files/html/line-graph.html +42 -42
  10. package/apps/charts/site_files/html/pie-chart-rounded-corners.html +38 -38
  11. package/apps/charts/site_files/html/simple-3D-pie-chart.html +43 -43
  12. package/apps/charts/site_files/js/chart-animated.js +2 -2
  13. package/apps/charts/site_files/json/PieChart.json +41 -41
  14. package/apps/charts/site_files/json/PieChart2.json +23 -23
  15. package/apps/charts/site_files/json/XYChart.json +74 -74
  16. package/apps/charts/site_files/json/bar-chart.json +99 -99
  17. package/apps/charts/site_files/json/column-chart.json +80 -80
  18. package/apps/charts/site_files/json/gauge.json +36 -36
  19. package/apps/charts/site_files/json/line-graph.json +1867 -1867
  20. package/apps/charts/site_files/json/pie-chart-rounded-corners.json +42 -42
  21. package/apps/charts/site_files/json/simple-3D-pie-chart.json +50 -50
  22. package/apps/client-side/package-lock.json +5 -5
  23. package/apps/client-side/package.json +21 -21
  24. package/apps/client-side/site_files/css/bootstrap3.css +5 -5
  25. package/apps/client-side/site_files/css/bootstrap4.css +6 -6
  26. package/apps/client-side/site_files/css/bootstrap5-addon.css +1 -1
  27. package/apps/client-side/site_files/css/bootstrap5.css +6 -6
  28. package/apps/client-side/site_files/css/checkbox.css +125 -125
  29. package/apps/client-side/site_files/css/font-awesome.css +4616 -4616
  30. package/apps/client-side/site_files/css/font-awesome.min.css +4 -4
  31. package/apps/client-side/site_files/css/fonts.css +85 -85
  32. package/apps/client-side/site_files/css/help.css +51 -51
  33. package/apps/client-side/site_files/css/images.css +4 -3
  34. package/apps/client-side/site_files/css/main-menu.css +66 -66
  35. package/apps/client-side/site_files/css/print.css +144 -144
  36. package/apps/client-side/site_files/css/prism.css +139 -139
  37. package/apps/client-side/site_files/css/progress.css +7 -7
  38. package/apps/client-side/site_files/css/radio.css +103 -103
  39. package/apps/client-side/site_files/css/scrollbar.css +13 -13
  40. package/apps/client-side/site_files/css/semantic.css +363 -363
  41. package/apps/client-side/site_files/css/table.css +87 -87
  42. package/apps/client-side/site_files/css/treeview.css +84 -84
  43. package/apps/client-side/site_files/css/ui.css +28 -28
  44. package/apps/client-side/site_files/fonts/fontawesome-webfont.svg +2671 -2671
  45. package/apps/client-side/site_files/fonts/glyphicons-halflings-regular.svg +287 -287
  46. package/apps/client-side/site_files/fonts/icons.svg +684 -684
  47. package/apps/client-side/site_files/js/angular-animate.js +4179 -4179
  48. package/apps/client-side/site_files/js/angular.js +36599 -36599
  49. package/apps/client-side/site_files/js/angular.min.js +351 -351
  50. package/apps/client-side/site_files/js/angular.min.js.map +8 -8
  51. package/apps/client-side/site_files/js/barcode.js +1 -1
  52. package/apps/client-side/site_files/js/base64.js +319 -319
  53. package/apps/client-side/site_files/js/bootstrap-5-directive.js +1456 -1456
  54. package/apps/client-side/site_files/js/bootstrap3.js +6 -6
  55. package/apps/client-side/site_files/js/bootstrap4.js +6 -6
  56. package/apps/client-side/site_files/js/bootstrap5.js +6 -6
  57. package/apps/client-side/site_files/js/custom.js +149 -149
  58. package/apps/client-side/site_files/js/directive.min.js +1 -1
  59. package/apps/client-side/site_files/js/hijri.js +965 -965
  60. package/apps/client-side/site_files/js/jquery.js +2 -2
  61. package/apps/client-side/site_files/js/moment.js +4511 -4511
  62. package/apps/client-side/site_files/js/prism.js +6 -6
  63. package/apps/client-side/site_files/js/qrcode.js +1398 -1398
  64. package/apps/client-side/site_files/js/semantic.js +10 -10
  65. package/apps/client-side/site_files/js/xlsx.js +23 -23
  66. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/brand-icons.svg +1008 -1008
  67. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/icons.svg +1518 -1518
  68. package/apps/client-side/site_files/semantic-themes/default/assets/fonts/outline-icons.svg +366 -366
  69. package/apps/client-side/site_files/webfonts/fa-brands-400.svg +3717 -3717
  70. package/apps/client-side/site_files/webfonts/fa-regular-400.svg +801 -801
  71. package/apps/client-side/site_files/webfonts/fa-solid-900.svg +5034 -5034
  72. package/apps/security/README.md +12 -12
  73. package/apps/security/app.js +288 -288
  74. package/apps/security/libs/notifications.js +89 -89
  75. package/apps/security/site_files/html/add_modal.html +36 -36
  76. package/apps/security/site_files/html/content.html +36 -36
  77. package/apps/security/site_files/html/delete_modal.html +31 -31
  78. package/apps/security/site_files/html/head.html +7 -7
  79. package/apps/security/site_files/html/index.html +80 -80
  80. package/apps/security/site_files/html/login_modal.html +24 -24
  81. package/apps/security/site_files/html/logout_modal.html +21 -21
  82. package/apps/security/site_files/html/navbar.html +8 -8
  83. package/apps/security/site_files/html/register_modal.html +32 -32
  84. package/apps/security/site_files/html/update_modal.html +28 -28
  85. package/apps/security/site_files/html/view.html +74 -74
  86. package/apps/security/site_files/html/view_modal.html +32 -32
  87. package/apps/security/site_files/js/app.js +1 -1
  88. package/apps/security/site_files/js/index.js +278 -278
  89. package/apps/security/site_files/js/login.js +35 -35
  90. package/apps/security/site_files/js/logout.js +22 -22
  91. package/apps/security/site_files/js/navbar.js +26 -26
  92. package/apps/security/site_files/js/register.js +30 -30
  93. package/apps/security/site_files/json/permissions.json +7 -7
  94. package/apps/security/site_files/json/roles.json +33 -33
  95. package/apps/security/site_files/json/words.json +28 -28
  96. package/gulpfile.js +17 -17
  97. package/index.js +1 -0
  98. package/isite.postman_collection.json +7 -7
  99. package/isite_files/css/bootstrap.css +5 -5
  100. package/isite_files/css/font-awesome.css +4 -4
  101. package/isite_files/css/prism.css +139 -139
  102. package/isite_files/fonts/fontawesome-webfont.svg +2671 -2671
  103. package/isite_files/fonts/glyphicons-halflings-regular.svg +287 -287
  104. package/isite_files/html/files.html +9 -9
  105. package/isite_files/html/head.html +12 -12
  106. package/isite_files/html/index.html +30 -30
  107. package/isite_files/html/installing.html +27 -27
  108. package/isite_files/html/navbar.html +51 -51
  109. package/isite_files/html/routes.html +13 -13
  110. package/isite_files/html/sessions.html +13 -13
  111. package/isite_files/html/vars.html +9 -9
  112. package/isite_files/js/angular.js +334 -334
  113. package/isite_files/js/bootstrap.js +6 -6
  114. package/isite_files/js/custom.js +149 -149
  115. package/isite_files/js/jquery.js +4 -4
  116. package/isite_files/js/prism.js +6 -6
  117. package/lib/README.md +1 -1
  118. package/lib/cookie.js +81 -81
  119. package/lib/dashboard.js +189 -189
  120. package/lib/mongodb.js +686 -686
  121. package/lib/parser.js +910 -910
  122. package/lib/session.js +158 -158
  123. package/lib/storage.js +6 -0
  124. package/lib/ws.js +4 -26
  125. package/object-options/lib/isite.code-workspace +10 -10
  126. package/object-options/lib/safty.js +13 -16
  127. package/package.json +55 -54
  128. package/ssl/create_ssl.sh +3 -3
@@ -1,965 +1,965 @@
1
- // moment-hijri.js
2
- // author: Suhail Alkowaileet
3
- // This is a modified version of moment-jalaali by Behrang Noruzi Niya
4
- // license: MIT
5
-
6
- 'use strict';
7
-
8
- /************************************
9
- Expose Moment Hijri
10
- ************************************/
11
- (function (root, factory) {
12
- /* global define */
13
- if (typeof define === 'function' && define.amd) {
14
- define(['moment'], function (moment) {
15
- root.moment = factory(moment)
16
- return root.moment
17
- })
18
- } else if (typeof exports === 'object') {
19
- module.exports = factory(require( __dirname + '/moment'))
20
- } else {
21
- root.moment = factory(root.moment)
22
- }
23
- })(this, function (moment) { // jshint ignore:line
24
-
25
- if (moment == null) {
26
- throw new Error('Cannot find moment')
27
- }
28
-
29
- /************************************
30
- Constants
31
- ************************************/
32
-
33
- var ummalqura = {
34
- ummalquraData: [28607, 28636, 28665, 28695, 28724, 28754, 28783, 28813, 28843, 28872, 28901, 28931, 28960, 28990, 29019, 29049, 29078, 29108, 29137, 29167,
35
- 29196, 29226, 29255, 29285, 29315, 29345, 29375, 29404, 29434, 29463, 29492, 29522, 29551, 29580, 29610, 29640, 29669, 29699, 29729, 29759,
36
- 29788, 29818, 29847, 29876, 29906, 29935, 29964, 29994, 30023, 30053, 30082, 30112, 30141, 30171, 30200, 30230, 30259, 30289, 30318, 30348,
37
- 30378, 30408, 30437, 30467, 30496, 30526, 30555, 30585, 30614, 30644, 30673, 30703, 30732, 30762, 30791, 30821, 30850, 30880, 30909, 30939,
38
- 30968, 30998, 31027, 31057, 31086, 31116, 31145, 31175, 31204, 31234, 31263, 31293, 31322, 31352, 31381, 31411, 31441, 31471, 31500, 31530,
39
- 31559, 31589, 31618, 31648, 31676, 31706, 31736, 31766, 31795, 31825, 31854, 31884, 31913, 31943, 31972, 32002, 32031, 32061, 32090, 32120,
40
- 32150, 32180, 32209, 32239, 32268, 32298, 32327, 32357, 32386, 32416, 32445, 32475, 32504, 32534, 32563, 32593, 32622, 32652, 32681, 32711,
41
- 32740, 32770, 32799, 32829, 32858, 32888, 32917, 32947, 32976, 33006, 33035, 33065, 33094, 33124, 33153, 33183, 33213, 33243, 33272, 33302,
42
- 33331, 33361, 33390, 33420, 33450, 33479, 33509, 33539, 33568, 33598, 33627, 33657, 33686, 33716, 33745, 33775, 33804, 33834, 33863, 33893,
43
- 33922, 33952, 33981, 34011, 34040, 34069, 34099, 34128, 34158, 34187, 34217, 34247, 34277, 34306, 34336, 34365, 34395, 34424, 34454, 34483,
44
- 34512, 34542, 34571, 34601, 34631, 34660, 34690, 34719, 34749, 34778, 34808, 34837, 34867, 34896, 34926, 34955, 34985, 35015, 35044, 35074,
45
- 35103, 35133, 35162, 35192, 35222, 35251, 35280, 35310, 35340, 35370, 35399, 35429, 35458, 35488, 35517, 35547, 35576, 35605, 35635, 35665,
46
- 35694, 35723, 35753, 35782, 35811, 35841, 35871, 35901, 35930, 35960, 35989, 36019, 36048, 36078, 36107, 36136, 36166, 36195, 36225, 36254,
47
- 36284, 36314, 36343, 36373, 36403, 36433, 36462, 36492, 36521, 36551, 36580, 36610, 36639, 36669, 36698, 36728, 36757, 36786, 36816, 36845,
48
- 36875, 36904, 36934, 36963, 36993, 37022, 37052, 37081, 37111, 37141, 37170, 37200, 37229, 37259, 37288, 37318, 37347, 37377, 37406, 37436,
49
- 37465, 37495, 37524, 37554, 37584, 37613, 37643, 37672, 37701, 37731, 37760, 37790, 37819, 37849, 37878, 37908, 37938, 37967, 37997, 38027,
50
- 38056, 38085, 38115, 38144, 38174, 38203, 38233, 38262, 38292, 38322, 38351, 38381, 38410, 38440, 38469, 38499, 38528, 38558, 38587, 38617,
51
- 38646, 38676, 38705, 38735, 38764, 38794, 38823, 38853, 38882, 38912, 38941, 38971, 39001, 39030, 39059, 39089, 39118, 39148, 39178, 39208,
52
- 39237, 39267, 39297, 39326, 39355, 39385, 39414, 39444, 39473, 39503, 39532, 39562, 39592, 39621, 39650, 39680, 39709, 39739, 39768, 39798,
53
- 39827, 39857, 39886, 39916, 39946, 39975, 40005, 40035, 40064, 40094, 40123, 40153, 40182, 40212, 40241, 40271, 40300, 40330, 40359, 40389,
54
- 40418, 40448, 40477, 40507, 40536, 40566, 40595, 40625, 40655, 40685, 40714, 40744, 40773, 40803, 40832, 40862, 40892, 40921, 40951, 40980,
55
- 41009, 41039, 41068, 41098, 41127, 41157, 41186, 41216, 41245, 41275, 41304, 41334, 41364, 41393, 41422, 41452, 41481, 41511, 41540, 41570,
56
- 41599, 41629, 41658, 41688, 41718, 41748, 41777, 41807, 41836, 41865, 41894, 41924, 41953, 41983, 42012, 42042, 42072, 42102, 42131, 42161,
57
- 42190, 42220, 42249, 42279, 42308, 42337, 42367, 42397, 42426, 42456, 42485, 42515, 42545, 42574, 42604, 42633, 42662, 42692, 42721, 42751,
58
- 42780, 42810, 42839, 42869, 42899, 42929, 42958, 42988, 43017, 43046, 43076, 43105, 43135, 43164, 43194, 43223, 43253, 43283, 43312, 43342,
59
- 43371, 43401, 43430, 43460, 43489, 43519, 43548, 43578, 43607, 43637, 43666, 43696, 43726, 43755, 43785, 43814, 43844, 43873, 43903, 43932,
60
- 43962, 43991, 44021, 44050, 44080, 44109, 44139, 44169, 44198, 44228, 44258, 44287, 44317, 44346, 44375, 44405, 44434, 44464, 44493, 44523,
61
- 44553, 44582, 44612, 44641, 44671, 44700, 44730, 44759, 44788, 44818, 44847, 44877, 44906, 44936, 44966, 44996, 45025, 45055, 45084, 45114,
62
- 45143, 45172, 45202, 45231, 45261, 45290, 45320, 45350, 45380, 45409, 45439, 45468, 45498, 45527, 45556, 45586, 45615, 45644, 45674, 45704,
63
- 45733, 45763, 45793, 45823, 45852, 45882, 45911, 45940, 45970, 45999, 46028, 46058, 46088, 46117, 46147, 46177, 46206, 46236, 46265, 46295,
64
- 46324, 46354, 46383, 46413, 46442, 46472, 46501, 46531, 46560, 46590, 46620, 46649, 46679, 46708, 46738, 46767, 46797, 46826, 46856, 46885,
65
- 46915, 46944, 46974, 47003, 47033, 47063, 47092, 47122, 47151, 47181, 47210, 47240, 47269, 47298, 47328, 47357, 47387, 47417, 47446, 47476,
66
- 47506, 47535, 47565, 47594, 47624, 47653, 47682, 47712, 47741, 47771, 47800, 47830, 47860, 47890, 47919, 47949, 47978, 48008, 48037, 48066,
67
- 48096, 48125, 48155, 48184, 48214, 48244, 48273, 48303, 48333, 48362, 48392, 48421, 48450, 48480, 48509, 48538, 48568, 48598, 48627, 48657,
68
- 48687, 48717, 48746, 48776, 48805, 48834, 48864, 48893, 48922, 48952, 48982, 49011, 49041, 49071, 49100, 49130, 49160, 49189, 49218, 49248,
69
- 49277, 49306, 49336, 49365, 49395, 49425, 49455, 49484, 49514, 49543, 49573, 49602, 49632, 49661, 49690, 49720, 49749, 49779, 49809, 49838,
70
- 49868, 49898, 49927, 49957, 49986, 50016, 50045, 50075, 50104, 50133, 50163, 50192, 50222, 50252, 50281, 50311, 50340, 50370, 50400, 50429,
71
- 50459, 50488, 50518, 50547, 50576, 50606, 50635, 50665, 50694, 50724, 50754, 50784, 50813, 50843, 50872, 50902, 50931, 50960, 50990, 51019,
72
- 51049, 51078, 51108, 51138, 51167, 51197, 51227, 51256, 51286, 51315, 51345, 51374, 51403, 51433, 51462, 51492, 51522, 51552, 51582, 51611,
73
- 51641, 51670, 51699, 51729, 51758, 51787, 51816, 51846, 51876, 51906, 51936, 51965, 51995, 52025, 52054, 52083, 52113, 52142, 52171, 52200,
74
- 52230, 52260, 52290, 52319, 52349, 52379, 52408, 52438, 52467, 52497, 52526, 52555, 52585, 52614, 52644, 52673, 52703, 52733, 52762, 52792,
75
- 52822, 52851, 52881, 52910, 52939, 52969, 52998, 53028, 53057, 53087, 53116, 53146, 53176, 53205, 53235, 53264, 53294, 53324, 53353, 53383,
76
- 53412, 53441, 53471, 53500, 53530, 53559, 53589, 53619, 53648, 53678, 53708, 53737, 53767, 53796, 53825, 53855, 53884, 53913, 53943, 53973,
77
- 54003, 54032, 54062, 54092, 54121, 54151, 54180, 54209, 54239, 54268, 54297, 54327, 54357, 54387, 54416, 54446, 54476, 54505, 54535, 54564,
78
- 54593, 54623, 54652, 54681, 54711, 54741, 54770, 54800, 54830, 54859, 54889, 54919, 54948, 54977, 55007, 55036, 55066, 55095, 55125, 55154,
79
- 55184, 55213, 55243, 55273, 55302, 55332, 55361, 55391, 55420, 55450, 55479, 55508, 55538, 55567, 55597, 55627, 55657, 55686, 55716, 55745,
80
- 55775, 55804, 55834, 55863, 55892, 55922, 55951, 55981, 56011, 56040, 56070, 56100, 56129, 56159, 56188, 56218, 56247, 56276, 56306, 56335,
81
- 56365, 56394, 56424, 56454, 56483, 56513, 56543, 56572, 56601, 56631, 56660, 56690, 56719, 56749, 56778, 56808, 56837, 56867, 56897, 56926,
82
- 56956, 56985, 57015, 57044, 57074, 57103, 57133, 57162, 57192, 57221, 57251, 57280, 57310, 57340, 57369, 57399, 57429, 57458, 57487, 57517,
83
- 57546, 57576, 57605, 57634, 57664, 57694, 57723, 57753, 57783, 57813, 57842, 57871, 57901, 57930, 57959, 57989, 58018, 58048, 58077, 58107,
84
- 58137, 58167, 58196, 58226, 58255, 58285, 58314, 58343, 58373, 58402, 58432, 58461, 58491, 58521, 58551, 58580, 58610, 58639, 58669, 58698,
85
- 58727, 58757, 58786, 58816, 58845, 58875, 58905, 58934, 58964, 58994, 59023, 59053, 59082, 59111, 59141, 59170, 59200, 59229, 59259, 59288,
86
- 59318, 59348, 59377, 59407, 59436, 59466, 59495, 59525, 59554, 59584, 59613, 59643, 59672, 59702, 59731, 59761, 59791, 59820, 59850, 59879,
87
- 59909, 59939, 59968, 59997, 60027, 60056, 60086, 60115, 60145, 60174, 60204, 60234, 60264, 60293, 60323, 60352, 60381, 60411, 60440, 60469,
88
- 60499, 60528, 60558, 60588, 60618, 60648, 60677, 60707, 60736, 60765, 60795, 60824, 60853, 60883, 60912, 60942, 60972, 61002, 61031, 61061,
89
- 61090, 61120, 61149, 61179, 61208, 61237, 61267, 61296, 61326, 61356, 61385, 61415, 61445, 61474, 61504, 61533, 61563, 61592, 61621, 61651,
90
- 61680, 61710, 61739, 61769, 61799, 61828, 61858, 61888, 61917, 61947, 61976, 62006, 62035, 62064, 62094, 62123, 62153, 62182, 62212, 62242,
91
- 62271, 62301, 62331, 62360, 62390, 62419, 62448, 62478, 62507, 62537, 62566, 62596, 62625, 62655, 62685, 62715, 62744, 62774, 62803, 62832,
92
- 62862, 62891, 62921, 62950, 62980, 63009, 63039, 63069, 63099, 63128, 63157, 63187, 63216, 63246, 63275, 63305, 63334, 63363, 63393, 63423,
93
- 63453, 63482, 63512, 63541, 63571, 63600, 63630, 63659, 63689, 63718, 63747, 63777, 63807, 63836, 63866, 63895, 63925, 63955, 63984, 64014,
94
- 64043, 64073, 64102, 64131, 64161, 64190, 64220, 64249, 64279, 64309, 64339, 64368, 64398, 64427, 64457, 64486, 64515, 64545, 64574, 64603,
95
- 64633, 64663, 64692, 64722, 64752, 64782, 64811, 64841, 64870, 64899, 64929, 64958, 64987, 65017, 65047, 65076, 65106, 65136, 65166, 65195,
96
- 65225, 65254, 65283, 65313, 65342, 65371, 65401, 65431, 65460, 65490, 65520, 65549, 65579, 65608, 65638, 65667, 65697, 65726, 65755, 65785,
97
- 65815, 65844, 65874, 65903, 65933, 65963, 65992, 66022, 66051, 66081, 66110, 66140, 66169, 66199, 66228, 66258, 66287, 66317, 66346, 66376,
98
- 66405, 66435, 66465, 66494, 66524, 66553, 66583, 66612, 66641, 66671, 66700, 66730, 66760, 66789, 66819, 66849, 66878, 66908, 66937, 66967,
99
- 66996, 67025, 67055, 67084, 67114, 67143, 67173, 67203, 67233, 67262, 67292, 67321, 67351, 67380, 67409, 67439, 67468, 67497, 67527, 67557,
100
- 67587, 67617, 67646, 67676, 67705, 67735, 67764, 67793, 67823, 67852, 67882, 67911, 67941, 67971, 68000, 68030, 68060, 68089, 68119, 68148,
101
- 68177, 68207, 68236, 68266, 68295, 68325, 68354, 68384, 68414, 68443, 68473, 68502, 68532, 68561, 68591, 68620, 68650, 68679, 68708, 68738,
102
- 68768, 68797, 68827, 68857, 68886, 68916, 68946, 68975, 69004, 69034, 69063, 69092, 69122, 69152, 69181, 69211, 69240, 69270, 69300, 69330,
103
- 69359, 69388, 69418, 69447, 69476, 69506, 69535, 69565, 69595, 69624, 69654, 69684, 69713, 69743, 69772, 69802, 69831, 69861, 69890, 69919,
104
- 69949, 69978, 70008, 70038, 70067, 70097, 70126, 70156, 70186, 70215, 70245, 70274, 70303, 70333, 70362, 70392, 70421, 70451, 70481, 70510,
105
- 70540, 70570, 70599, 70629, 70658, 70687, 70717, 70746, 70776, 70805, 70835, 70864, 70894, 70924, 70954, 70983, 71013, 71042, 71071, 71101,
106
- 71130, 71159, 71189, 71218, 71248, 71278, 71308, 71337, 71367, 71397, 71426, 71455, 71485, 71514, 71543, 71573, 71602, 71632, 71662, 71691,
107
- 71721, 71751, 71781, 71810, 71839, 71869, 71898, 71927, 71957, 71986, 72016, 72046, 72075, 72105, 72135, 72164, 72194, 72223, 72253, 72282,
108
- 72311, 72341, 72370, 72400, 72429, 72459, 72489, 72518, 72548, 72577, 72607, 72637, 72666, 72695, 72725, 72754, 72784, 72813, 72843, 72872,
109
- 72902, 72931, 72961, 72991, 73020, 73050, 73080, 73109, 73139, 73168, 73197, 73227, 73256, 73286, 73315, 73345, 73375, 73404, 73434, 73464,
110
- 73493, 73523, 73552, 73581, 73611, 73640, 73669, 73699, 73729, 73758, 73788, 73818, 73848, 73877, 73907, 73936, 73965, 73995, 74024, 74053,
111
- 74083, 74113, 74142, 74172, 74202, 74231, 74261, 74291, 74320, 74349, 74379, 74408, 74437, 74467, 74497, 74526, 74556, 74586, 74615, 74645,
112
- 74675, 74704, 74733, 74763, 74792, 74822, 74851, 74881, 74910, 74940, 74969, 74999, 75029, 75058, 75088, 75117, 75147, 75176, 75206, 75235,
113
- 75264, 75294, 75323, 75353, 75383, 75412, 75442, 75472, 75501, 75531, 75560, 75590, 75619, 75648, 75678, 75707, 75737, 75766, 75796, 75826,
114
- 75856, 75885, 75915, 75944, 75974, 76003, 76032, 76062, 76091, 76121, 76150, 76180, 76210, 76239, 76269, 76299, 76328, 76358, 76387, 76416,
115
- 76446, 76475, 76505, 76534, 76564, 76593, 76623, 76653, 76682, 76712, 76741, 76771, 76801, 76830, 76859, 76889, 76918, 76948, 76977, 77007,
116
- 77036, 77066, 77096, 77125, 77155, 77185, 77214, 77243, 77273, 77302, 77332, 77361, 77390, 77420, 77450, 77479, 77509, 77539, 77569, 77598,
117
- 77627, 77657, 77686, 77715, 77745, 77774, 77804, 77833, 77863, 77893, 77923, 77952, 77982, 78011, 78041, 78070, 78099, 78129, 78158, 78188,
118
- 78217, 78247, 78277, 78307, 78336, 78366, 78395, 78425, 78454, 78483, 78513, 78542, 78572, 78601, 78631, 78661, 78690, 78720, 78750, 78779,
119
- 78808, 78838, 78867, 78897, 78926, 78956, 78985, 79015, 79044, 79074, 79104, 79133, 79163, 79192, 79222, 79251, 79281, 79310, 79340, 79369,
120
- 79399, 79428, 79458, 79487, 79517, 79546, 79576, 79606, 79635, 79665, 79695, 79724, 79753, 79783, 79812, 79841, 79871, 79900, 79930, 79960,
121
- 79990]
122
- }
123
-
124
- var formattingTokens = /(\[[^\[]*\])|(\\)?i(Mo|MM?M?M?|Do|DDDo|DD?D?D?|w[o|w]?|YYYYY|YYYY|YY|gg(ggg?)?)|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,
125
- localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g
126
-
127
- , parseTokenOneOrTwoDigits = /\d\d?/, parseTokenOneToThreeDigits = /\d{1,3}/, parseTokenThreeDigits = /\d{3}/, parseTokenFourDigits = /\d{1,4}/, parseTokenSixDigits = /[+\-]?\d{1,6}/, parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.?)|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i, parseTokenT = /T/i, parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/
128
-
129
- , unitAliases = {
130
- hd: 'idate',
131
- hm: 'imonth',
132
- hy: 'iyear'
133
- }
134
-
135
- , formatFunctions = {}
136
-
137
- , ordinalizeTokens = 'DDD w M D'.split(' '), paddedTokens = 'M D w'.split(' ')
138
-
139
- , formatTokenFunctions = {
140
- iM: function () {
141
- return this.iMonth() + 1
142
- },
143
- iMMM: function (format) {
144
- return this.localeData().iMonthsShort(this, format)
145
- },
146
- iMMMM: function (format) {
147
- return this.localeData().iMonths(this, format)
148
- },
149
- iD: function () {
150
- return this.iDate()
151
- },
152
- iDDD: function () {
153
- return this.iDayOfYear()
154
- },
155
- iw: function () {
156
- return this.iWeek()
157
- },
158
- iYY: function () {
159
- return leftZeroFill(this.iYear() % 100, 2)
160
- },
161
- iYYYY: function () {
162
- return leftZeroFill(this.iYear(), 4)
163
- },
164
- iYYYYY: function () {
165
- return leftZeroFill(this.iYear(), 5)
166
- },
167
- igg: function () {
168
- return leftZeroFill(this.iWeekYear() % 100, 2)
169
- },
170
- igggg: function () {
171
- return this.iWeekYear()
172
- },
173
- iggggg: function () {
174
- return leftZeroFill(this.iWeekYear(), 5)
175
- }
176
- }, i
177
-
178
- function padToken(func, count) {
179
- return function (a) {
180
- return leftZeroFill(func.call(this, a), count)
181
- }
182
- }
183
-
184
- function ordinalizeToken(func, period) {
185
- return function (a) {
186
- return this.localeData().ordinal(func.call(this, a), period)
187
- }
188
- }
189
-
190
- while (ordinalizeTokens.length) {
191
- i = ordinalizeTokens.pop()
192
- formatTokenFunctions['i' + i + 'o'] = ordinalizeToken(formatTokenFunctions['i' + i], i)
193
- }
194
- while (paddedTokens.length) {
195
- i = paddedTokens.pop()
196
- formatTokenFunctions['i' + i + i] = padToken(formatTokenFunctions['i' + i], 2)
197
- }
198
- formatTokenFunctions.iDDDD = padToken(formatTokenFunctions.iDDD, 3)
199
-
200
- /************************************
201
- Helpers
202
- ************************************/
203
-
204
- function extend(a, b) {
205
- var key
206
- for (key in b)
207
- if (b.hasOwnProperty(key))
208
- a[key] = b[key]
209
- return a
210
- }
211
-
212
- function leftZeroFill(number, targetLength) {
213
- var output = number + ''
214
- while (output.length < targetLength)
215
- output = '0' + output
216
- return output
217
- }
218
-
219
- function isArray(input) {
220
- return Object.prototype.toString.call(input) === '[object Array]'
221
- }
222
-
223
- function normalizeUnits(units) {
224
- return units ? unitAliases[units] || units.toLowerCase().replace(/(.)s$/, '$1') : units
225
- }
226
-
227
- function setDate(moment, year, month, date) {
228
- var utc = moment._isUTC ? 'UTC' : ''
229
- moment._d['set' + utc + 'FullYear'](year)
230
- moment._d['set' + utc + 'Month'](month)
231
- moment._d['set' + utc + 'Date'](date)
232
- }
233
-
234
- function objectCreate(parent) {
235
- function F() {}
236
- F.prototype = parent
237
- return new F()
238
- }
239
-
240
- function getPrototypeOf(object) {
241
- if (Object.getPrototypeOf)
242
- return Object.getPrototypeOf(object)
243
- else if (''.__proto__) // jshint ignore:line
244
- return object.__proto__ // jshint ignore:line
245
- else
246
- return object.constructor.prototype
247
- }
248
-
249
- /************************************
250
- Languages
251
- ************************************/
252
- extend(getPrototypeOf(moment.localeData()), {
253
- _iMonths: ['Muharram'
254
- , 'Safar'
255
- , 'Rabi\' al-Awwal'
256
- , 'Rabi\' al-Thani'
257
- , 'Jumada al-Ula'
258
- , 'Jumada al-Alkhirah'
259
- , 'Rajab'
260
- , 'Sha’ban'
261
- , 'Ramadhan'
262
- , 'Shawwal'
263
- , 'Thul-Qi’dah'
264
- , 'Thul-Hijjah'
265
- ],
266
- iMonths: function (m) {
267
- return this._iMonths[m.iMonth()]
268
- }
269
-
270
- ,
271
- _iMonthsShort: ['Muh'
272
- , 'Saf'
273
- , 'Rab-I'
274
- , 'Rab-II'
275
- , 'Jum-I'
276
- , 'Jum-II'
277
- , 'Raj'
278
- , 'Sha'
279
- , 'Ram'
280
- , 'Shw'
281
- , 'Dhu-Q'
282
- , 'Dhu-H'
283
- ],
284
- iMonthsShort: function (m) {
285
- return this._iMonthsShort[m.iMonth()]
286
- }
287
-
288
- ,
289
- iMonthsParse: function (monthName) {
290
- var i, mom, regex
291
- if (!this._iMonthsParse)
292
- this._iMonthsParse = []
293
- for (i = 0; i < 12; i += 1) {
294
- // Make the regex if we don't have it already.
295
- if (!this._iMonthsParse[i]) {
296
- mom = hMoment([2000, (2 + i) % 12, 25])
297
- regex = '^' + this.iMonths(mom, '') + '$|^' + this.iMonthsShort(mom, '') + '$'
298
- this._iMonthsParse[i] = new RegExp(regex.replace('.', ''), 'i')
299
- }
300
- // Test the regex.
301
- if (this._iMonthsParse[i].test(monthName))
302
- return i
303
- }
304
- }
305
- });
306
- var iMonthNames = {
307
- iMonths: 'محرم_صفر_ربيع الأول_ربيع الثاني_جمادى الأولى_جمادى الآخرة_رجب_شعبان_رمضان_شوال_ذو القعدة_ذو الحجة'.split('_'),
308
- iMonthsShort: 'محرم_صفر_ربيع ١_ربيع ٢_جمادى ١_جمادى ٢_رجب_شعبان_رمضان_شوال_ذو القعدة_ذو الحجة'.split('_')
309
- };
310
-
311
- // Default to the momentjs 2.12+ API
312
- if (typeof moment.updateLocale === 'function') {
313
- moment.updateLocale('ar-sa', iMonthNames);
314
- } else {
315
- var oldLocale = moment.locale();
316
- moment.defineLocale('ar-sa', iMonthNames);
317
- moment.locale(oldLocale);
318
- }
319
-
320
- /************************************
321
- Formatting
322
- ************************************/
323
-
324
- function makeFormatFunction(format) {
325
- var array = format.match(formattingTokens),
326
- length = array.length,
327
- i
328
-
329
- for (i = 0; i < length; i += 1)
330
- if (formatTokenFunctions[array[i]])
331
- array[i] = formatTokenFunctions[array[i]]
332
-
333
- return function (mom) {
334
- var output = ''
335
- for (i = 0; i < length; i += 1)
336
- output += array[i] instanceof Function ? '[' + array[i].call(mom, format) + ']' : array[i]
337
- return output
338
- }
339
- }
340
-
341
- /************************************
342
- Parsing
343
- ************************************/
344
-
345
- function getParseRegexForToken(token, config) {
346
- switch (token) {
347
- case 'iDDDD':
348
- return parseTokenThreeDigits
349
- case 'iYYYY':
350
- return parseTokenFourDigits
351
- case 'iYYYYY':
352
- return parseTokenSixDigits
353
- case 'iDDD':
354
- return parseTokenOneToThreeDigits
355
- case 'iMMM':
356
- case 'iMMMM':
357
- return parseTokenWord
358
- case 'iMM':
359
- case 'iDD':
360
- case 'iYY':
361
- case 'iM':
362
- case 'iD':
363
- return parseTokenOneOrTwoDigits
364
- case 'DDDD':
365
- return parseTokenThreeDigits
366
- case 'YYYY':
367
- return parseTokenFourDigits
368
- case 'YYYYY':
369
- return parseTokenSixDigits
370
- case 'S':
371
- case 'SS':
372
- case 'SSS':
373
- case 'DDD':
374
- return parseTokenOneToThreeDigits
375
- case 'MMM':
376
- case 'MMMM':
377
- case 'dd':
378
- case 'ddd':
379
- case 'dddd':
380
- return parseTokenWord
381
- case 'a':
382
- case 'A':
383
- return moment.localeData(config._l)._meridiemParse
384
- case 'X':
385
- return parseTokenTimestampMs
386
- case 'Z':
387
- case 'ZZ':
388
- return parseTokenTimezone
389
- case 'T':
390
- return parseTokenT
391
- case 'MM':
392
- case 'DD':
393
- case 'YY':
394
- case 'HH':
395
- case 'hh':
396
- case 'mm':
397
- case 'ss':
398
- case 'M':
399
- case 'D':
400
- case 'd':
401
- case 'H':
402
- case 'h':
403
- case 'm':
404
- case 's':
405
- return parseTokenOneOrTwoDigits
406
- default:
407
- return new RegExp(token.replace('\\', ''))
408
- }
409
- }
410
-
411
- function addTimeToArrayFromToken(token, input, config) {
412
- var a, datePartArray = config._a
413
-
414
- switch (token) {
415
- case 'iM':
416
- case 'iMM':
417
- datePartArray[1] = input == null ? 0 : ~~input - 1
418
- break
419
- case 'iMMM':
420
- case 'iMMMM':
421
- a = moment.localeData(config._l).iMonthsParse(input)
422
- if (a != null)
423
- datePartArray[1] = a
424
- else
425
- config._isValid = !1
426
- break
427
- case 'iD':
428
- case 'iDD':
429
- case 'iDDD':
430
- case 'iDDDD':
431
- if (input != null)
432
- datePartArray[2] = ~~input
433
- break
434
- case 'iYY':
435
- datePartArray[0] = ~~input + (~~input > 47 ? 1300 : 1400)
436
- break
437
- case 'iYYYY':
438
- case 'iYYYYY':
439
- datePartArray[0] = ~~input
440
- }
441
- if (input == null)
442
- config._isValid = !1
443
- }
444
-
445
- function dateFromArray(config) {
446
- var g, h, hy = config._a[0],
447
- hm = config._a[1],
448
- hd = config._a[2]
449
-
450
- if ((hy == null) && (hm == null) && (hd == null))
451
- return [0, 0, 1]
452
- hy = hy || 0
453
- hm = hm || 0
454
- hd = hd || 1
455
- if (hd < 1 || hd > hMoment.iDaysInMonth(hy, hm))
456
- config._isValid = !1
457
- g = toGregorian(hy, hm, hd)
458
- h = toHijri(g.gy, g.gm, g.gd)
459
- config._hDiff = 0
460
- if (~~h.hy !== hy)
461
- config._hDiff += 1
462
- if (~~h.hm !== hm)
463
- config._hDiff += 1
464
- if (~~h.hd !== hd)
465
- config._hDiff += 1
466
- return [g.gy, g.gm, g.gd]
467
- }
468
-
469
- function makeDateFromStringAndFormat(config) {
470
- var tokens = config._f.match(formattingTokens),
471
- string = config._i,
472
- len = tokens.length,
473
- i, token, parsedInput
474
-
475
- config._a = []
476
-
477
- for (i = 0; i < len; i += 1) {
478
- token = tokens[i]
479
- parsedInput = (getParseRegexForToken(token, config).exec(string) || [])[0];
480
- if (parsedInput)
481
- string = string.slice(string.indexOf(parsedInput) + parsedInput.length)
482
- if (formatTokenFunctions[token])
483
- addTimeToArrayFromToken(token, parsedInput, config)
484
- }
485
- if (string)
486
- config._il = string
487
-
488
- return dateFromArray(config)
489
- }
490
-
491
- function makeDateFromStringAndArray(config, utc) {
492
- var len = config._f.length
493
- , i
494
- , format
495
- , tempMoment
496
- , bestMoment
497
- , currentScore
498
- , scoreToBeat
499
-
500
- if (len === 0) {
501
- return makeMoment(new Date(NaN))
502
- }
503
-
504
- for (i = 0; i < len; i += 1) {
505
- format = config._f[i]
506
- currentScore = 0
507
- tempMoment = makeMoment(config._i, format, config._l, utc)
508
-
509
- if (!tempMoment.isValid()) continue
510
-
511
- currentScore += tempMoment._hDiff
512
- if (tempMoment._il)
513
- currentScore += tempMoment._il.length
514
- if (scoreToBeat == null || currentScore < scoreToBeat) {
515
- scoreToBeat = currentScore
516
- bestMoment = tempMoment
517
- }
518
- }
519
-
520
- return bestMoment
521
- }
522
-
523
- function removeParsedTokens(config) {
524
- var string = config._i,
525
- input = '',
526
- format = '',
527
- array = config._f.match(formattingTokens),
528
- len = array.length,
529
- i, match, parsed
530
-
531
- for (i = 0; i < len; i += 1) {
532
- match = array[i]
533
- parsed = (getParseRegexForToken(match, config).exec(string) || [])[0]
534
- if (parsed)
535
- string = string.slice(string.indexOf(parsed) + parsed.length)
536
- if (!(formatTokenFunctions[match] instanceof Function)) {
537
- format += match
538
- if (parsed)
539
- input += parsed
540
- }
541
- }
542
- config._i = input
543
- config._f = format
544
- }
545
-
546
- /************************************
547
- Week of Year
548
- ************************************/
549
-
550
- function iWeekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
551
- var end = firstDayOfWeekOfYear - firstDayOfWeek,
552
- daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
553
- adjustedMoment
554
-
555
- if (daysToDayOfWeek > end) {
556
- daysToDayOfWeek -= 7
557
- }
558
- if (daysToDayOfWeek < end - 7) {
559
- daysToDayOfWeek += 7
560
- }
561
- adjustedMoment = hMoment(mom).add(daysToDayOfWeek, 'd')
562
- return {
563
- week: Math.ceil(adjustedMoment.iDayOfYear() / 7),
564
- year: adjustedMoment.iYear()
565
- }
566
- }
567
-
568
- /************************************
569
- Top Level Functions
570
- ************************************/
571
-
572
- function makeMoment(input, format, lang, utc) {
573
- var config =
574
- { _i: input
575
- , _f: format
576
- , _l: lang
577
- }
578
- , date
579
- , m
580
- , hm
581
- if (format) {
582
- if (isArray(format)) {
583
- return makeDateFromStringAndArray(config, utc)
584
- } else {
585
- date = makeDateFromStringAndFormat(config)
586
- removeParsedTokens(config)
587
- format = 'YYYY-MM-DD-' + config._f
588
- input = leftZeroFill(date[0], 4) + '-'
589
- + leftZeroFill(date[1] + 1, 2) + '-'
590
- + leftZeroFill(date[2], 2) + '-'
591
- + config._i
592
- }
593
- }
594
- if (utc)
595
- m = moment.utc(input, format, lang)
596
- else
597
- m = moment(input, format, lang)
598
- if (config._isValid === !1)
599
- m._isValid = !1
600
- m._hDiff = config._hDiff || 0
601
- hm = objectCreate(hMoment.fn)
602
- extend(hm, m)
603
- return hm
604
- }
605
-
606
- function hMoment(input, format, lang) {
607
- return makeMoment(input, format, lang, !1)
608
- }
609
-
610
- extend(hMoment, moment)
611
- hMoment.fn = objectCreate(moment.fn)
612
-
613
- hMoment.utc = function (input, format, lang) {
614
- return makeMoment(input, format, lang, !0)
615
- }
616
-
617
- /************************************
618
- hMoment Prototype
619
- ************************************/
620
-
621
- hMoment.fn.format = function (format) {
622
- var i, replace, me = this
623
-
624
- if (format) {
625
- i = 5
626
- replace = function (input) {
627
- return me.localeData().longDateFormat(input) || input
628
- }
629
- while (i > 0 && localFormattingTokens.test(format)) {
630
- i -= 1
631
- format = format.replace(localFormattingTokens, replace)
632
- }
633
- if (!formatFunctions[format]) {
634
- formatFunctions[format] = makeFormatFunction(format)
635
- }
636
- format = formatFunctions[format](this)
637
- }
638
- return moment.fn.format.call(this, format)
639
- }
640
-
641
- hMoment.fn.iYear = function (input) {
642
- var lastDay, h, g
643
- if (typeof input === 'number') {
644
- h = toHijri(this.year(), this.month(), this.date())
645
- lastDay = Math.min(h.hd, hMoment.iDaysInMonth(input, h.hm))
646
- g = toGregorian(input, h.hm, lastDay)
647
- setDate(this, g.gy, g.gm, g.gd)
648
- //Workaround: sometimes moment wont set the date correctly if current day is the last in the month
649
- if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
650
- setDate(this, g.gy, g.gm, g.gd)
651
- }
652
- moment.updateOffset(this)
653
- return this
654
- } else {
655
- return toHijri(this.year(), this.month(), this.date()).hy
656
- }
657
- }
658
-
659
- hMoment.fn.iMonth = function (input) {
660
- var lastDay, h, g
661
- if (input != null) {
662
- if (typeof input === 'string') {
663
- input = this.localeData().iMonthsParse(input)
664
- if(input >= 0) {
665
- input -= 1
666
- } else {
667
- return this
668
- }
669
- }
670
- h = toHijri(this.year(), this.month(), this.date())
671
- lastDay = Math.min(h.hd, hMoment.iDaysInMonth(h.hy, input))
672
- this.iYear(h.hy + div(input, 12))
673
- input = mod(input, 12)
674
- if (input < 0) {
675
- input += 12
676
- this.iYear(this.iYear() - 1)
677
- }
678
- g = toGregorian(this.iYear(), input, lastDay)
679
- setDate(this, g.gy, g.gm, g.gd)
680
- //Workaround: sometimes moment wont set the date correctly if current day is the last in the month
681
- if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
682
- setDate(this, g.gy, g.gm, g.gd)
683
- }
684
- moment.updateOffset(this)
685
- return this
686
- } else {
687
- return toHijri(this.year(), this.month(), this.date()).hm
688
- }
689
- }
690
-
691
- hMoment.fn.iDate = function (input) {
692
- var h, g
693
- if (typeof input === 'number') {
694
- h = toHijri(this.year(), this.month(), this.date())
695
- g = toGregorian(h.hy, h.hm, input)
696
- setDate(this, g.gy, g.gm, g.gd)
697
- //Workaround: sometimes moment wont set the date correctly if current day is the last in the month
698
- if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
699
- setDate(this, g.gy, g.gm, g.gd)
700
- }
701
- moment.updateOffset(this)
702
- return this
703
- } else {
704
- return toHijri(this.year(), this.month(), this.date()).hd
705
- }
706
- }
707
-
708
- hMoment.fn.iDayOfYear = function (input) {
709
- var dayOfYear = Math.round((hMoment(this).startOf('day') - hMoment(this).startOf('iYear')) / 864e5) + 1
710
- return input == null ? dayOfYear : this.add(input - dayOfYear, 'd')
711
- }
712
-
713
- hMoment.fn.iDaysInMonth = function () {
714
- return parseInt(hMoment(this).endOf('iMonth').format('iDD'));
715
- }
716
-
717
- hMoment.fn.iWeek = function (input) {
718
- var week = iWeekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).week
719
- return input == null ? week : this.add( (input - week) * 7, 'd')
720
- }
721
-
722
- hMoment.fn.iWeekYear = function (input) {
723
- var year = iWeekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year
724
- return input == null ? year : this.add(input - year, 'y')
725
- }
726
-
727
- hMoment.fn.add = function (val, units) {
728
- var temp
729
- if (units !== null && !isNaN(+units)) {
730
- temp = val
731
- val = units
732
- units = temp
733
- }
734
- units = normalizeUnits(units)
735
- if (units === 'iyear') {
736
- this.iYear(this.iYear() + val)
737
- } else if (units === 'imonth') {
738
- this.iMonth(this.iMonth() + val)
739
- } else if (units === 'idate') {
740
- this.iDate(this.iDate() + val)
741
- }
742
- else {
743
- moment.fn.add.call(this, val, units)
744
- }
745
- return this
746
- }
747
-
748
- hMoment.fn.subtract = function (val, units) {
749
- var temp
750
- if (units !== null && !isNaN(+units)) {
751
- temp = val
752
- val = units
753
- units = temp
754
- }
755
- units = normalizeUnits(units)
756
- if (units === 'iyear') {
757
- this.iYear(this.iYear() - val)
758
- } else if (units === 'imonth') {
759
- this.iMonth(this.iMonth() - val)
760
- } else if (units === 'idate') {
761
- this.iDate(this.iDate() - val)
762
- } else {
763
- moment.fn.subtract.call(this, val, units)
764
- }
765
- return this
766
- }
767
-
768
- hMoment.fn.startOf = function (units) {
769
- units = normalizeUnits(units)
770
- if (units === 'iyear' || units === 'imonth') {
771
- if (units === 'iyear') {
772
- this.iMonth(0)
773
- }
774
- this.iDate(1)
775
- this.hours(0)
776
- this.minutes(0)
777
- this.seconds(0)
778
- this.milliseconds(0)
779
- return this
780
- } else {
781
- return moment.fn.startOf.call(this, units)
782
- }
783
- }
784
-
785
- hMoment.fn.endOf = function (units) {
786
- units = normalizeUnits(units)
787
- if (units === undefined || units === 'milisecond') {
788
- return this
789
- }
790
- return this.startOf(units).add(1, (units === 'isoweek' ? 'week' : units)).subtract(1, 'milliseconds')
791
- }
792
-
793
- hMoment.fn.clone = function () {
794
- return hMoment(this)
795
- }
796
-
797
- hMoment.fn.iYears = hMoment.fn.iYear
798
- hMoment.fn.iMonths = hMoment.fn.iMonth
799
- hMoment.fn.iDates = hMoment.fn.iDate
800
- hMoment.fn.iWeeks = hMoment.fn.iWeek
801
-
802
- /************************************
803
- hMoment Statics
804
- ************************************/
805
-
806
- hMoment.iDaysInMonth = function (year, month) {
807
- var i = getNewMoonMJDNIndex(year, month + 1),
808
- daysInMonth = ummalqura.ummalquraData[i] - ummalqura.ummalquraData[i - 1]
809
- return daysInMonth
810
- }
811
-
812
- function toHijri(gy, gm, gd) {
813
- var h = d2h(g2d(gy, gm + 1, gd))
814
- h.hm -= 1
815
- return h
816
- }
817
-
818
- function toGregorian(hy, hm, hd) {
819
- var g = d2g(h2d(hy, hm + 1, hd))
820
- g.gm -= 1
821
- return g
822
- }
823
-
824
- hMoment.iConvert = {
825
- toHijri: toHijri,
826
- toGregorian: toGregorian
827
- }
828
-
829
- return hMoment
830
-
831
- /************************************
832
- Hijri Conversion
833
- ************************************/
834
-
835
- /*
836
- Utility helper functions.
837
- */
838
-
839
- function div(a, b) {
840
- return~~ (a / b)
841
- }
842
-
843
- function mod(a, b) {
844
- return a - ~~(a / b) * b
845
- }
846
-
847
- /*
848
- Converts a date of the Hijri calendar to the Julian Day number.
849
-
850
- @param hy Hijri year (1356 to 1500)
851
- @param hm Hijri month (1 to 12)
852
- @param hd Hijri day (1 to 29/30)
853
- @return Julian Day number
854
- */
855
-
856
- function h2d(hy, hm, hd) {
857
- var i = getNewMoonMJDNIndex(hy, hm),
858
- mjdn = hd + ummalqura.ummalquraData[i - 1] - 1,
859
- jdn = mjdn + 2400000;
860
- return jdn
861
- }
862
-
863
- /*
864
- Converts the Julian Day number to a date in the Hijri calendar.
865
-
866
- @param jdn Julian Day number
867
- @return
868
- hy: Hijri year (1356 to 1500)
869
- hm: Hijri month (1 to 12)
870
- hd: Hijri day (1 to 29/30)
871
- */
872
-
873
- function d2h(jdn) {
874
- var mjdn = jdn - 2400000,
875
- i = getNewMoonMJDNIndexByJDN(mjdn),
876
- totalMonths = i + 16260,
877
- cYears = Math.floor((totalMonths - 1) / 12),
878
- hy = cYears + 1,
879
- hm = totalMonths - 12 * cYears,
880
- hd = mjdn - ummalqura.ummalquraData[i - 1] + 1
881
-
882
- return {
883
- hy: hy,
884
- hm: hm,
885
- hd: hd
886
- }
887
- }
888
-
889
- /*
890
- Calculates the Julian Day number from Gregorian or Julian
891
- calendar dates. This integer number corresponds to the noon of
892
- the date (i.e. 12 hours of Universal Time).
893
- The procedure was tested to be good since 1 March, -100100 (of both
894
- calendars) up to a few million years into the future.
895
-
896
- @param gy Calendar year (years BC numbered 0, -1, -2, ...)
897
- @param gm Calendar month (1 to 12)
898
- @param gd Calendar day of the month (1 to 28/29/30/31)
899
- @return Julian Day number
900
- */
901
-
902
- function g2d(gy, gm, gd) {
903
- var d = div((gy + div(gm - 8, 6) + 100100) * 1461, 4) + div(153 * mod(gm + 9, 12) + 2, 5) + gd - 34840408
904
- d = d - div(div(gy + 100100 + div(gm - 8, 6), 100) * 3, 4) + 752
905
- return d
906
- }
907
-
908
- /*
909
- Calculates Gregorian and Julian calendar dates from the Julian Day number
910
- (hdn) for the period since jdn=-34839655 (i.e. the year -100100 of both
911
- calendars) to some millions years ahead of the present.
912
-
913
- @param jdn Julian Day number
914
- @return
915
- gy: Calendar year (years BC numbered 0, -1, -2, ...)
916
- gm: Calendar month (1 to 12)
917
- gd: Calendar day of the month M (1 to 28/29/30/31)
918
- */
919
-
920
- function d2g(jdn) {
921
- var j, i, gd, gm, gy
922
- j = 4 * jdn + 139361631
923
- j = j + div(div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908
924
- i = div(mod(j, 1461), 4) * 5 + 308
925
- gd = div(mod(i, 153), 5) + 1
926
- gm = mod(div(i, 153), 12) + 1
927
- gy = div(j, 1461) - 100100 + div(8 - gm, 6)
928
- return {
929
- gy: gy,
930
- gm: gm,
931
- gd: gd
932
- }
933
- }
934
-
935
- /*
936
- Returns the index of the modified Julian day number of the new moon
937
- by the given year and month
938
-
939
- @param hy: Hijri year (1356 to 1500)
940
- @param hm: Hijri month (1 to 12)
941
- @return
942
- i: the index of the new moon in modified Julian day number.
943
- */
944
- function getNewMoonMJDNIndex(hy, hm) {
945
- var cYears = hy - 1,
946
- totalMonths = (cYears * 12) + 1 + (hm - 1),
947
- i = totalMonths - 16260
948
- return i
949
- }
950
-
951
- /*
952
- Returns the nearest new moon
953
-
954
- @param jdn Julian Day number
955
- @return
956
- i: the index of a modified Julian day number.
957
- */
958
- function getNewMoonMJDNIndexByJDN(mjdn) {
959
- for (var i = 0; i < ummalqura.ummalquraData.length; i=i+1) {
960
- if (ummalqura.ummalquraData[i] > mjdn)
961
- return i
962
- }
963
- }
964
-
965
- });
1
+ // moment-hijri.js
2
+ // author: Suhail Alkowaileet
3
+ // This is a modified version of moment-jalaali by Behrang Noruzi Niya
4
+ // license: MIT
5
+
6
+ 'use strict';
7
+
8
+ /************************************
9
+ Expose Moment Hijri
10
+ ************************************/
11
+ (function (root, factory) {
12
+ /* global define */
13
+ if (typeof define === 'function' && define.amd) {
14
+ define(['moment'], function (moment) {
15
+ root.moment = factory(moment)
16
+ return root.moment
17
+ })
18
+ } else if (typeof exports === 'object') {
19
+ module.exports = factory(require( __dirname + '/moment'))
20
+ } else {
21
+ root.moment = factory(root.moment)
22
+ }
23
+ })(this, function (moment) { // jshint ignore:line
24
+
25
+ if (moment == null) {
26
+ throw new Error('Cannot find moment')
27
+ }
28
+
29
+ /************************************
30
+ Constants
31
+ ************************************/
32
+
33
+ var ummalqura = {
34
+ ummalquraData: [28607, 28636, 28665, 28695, 28724, 28754, 28783, 28813, 28843, 28872, 28901, 28931, 28960, 28990, 29019, 29049, 29078, 29108, 29137, 29167,
35
+ 29196, 29226, 29255, 29285, 29315, 29345, 29375, 29404, 29434, 29463, 29492, 29522, 29551, 29580, 29610, 29640, 29669, 29699, 29729, 29759,
36
+ 29788, 29818, 29847, 29876, 29906, 29935, 29964, 29994, 30023, 30053, 30082, 30112, 30141, 30171, 30200, 30230, 30259, 30289, 30318, 30348,
37
+ 30378, 30408, 30437, 30467, 30496, 30526, 30555, 30585, 30614, 30644, 30673, 30703, 30732, 30762, 30791, 30821, 30850, 30880, 30909, 30939,
38
+ 30968, 30998, 31027, 31057, 31086, 31116, 31145, 31175, 31204, 31234, 31263, 31293, 31322, 31352, 31381, 31411, 31441, 31471, 31500, 31530,
39
+ 31559, 31589, 31618, 31648, 31676, 31706, 31736, 31766, 31795, 31825, 31854, 31884, 31913, 31943, 31972, 32002, 32031, 32061, 32090, 32120,
40
+ 32150, 32180, 32209, 32239, 32268, 32298, 32327, 32357, 32386, 32416, 32445, 32475, 32504, 32534, 32563, 32593, 32622, 32652, 32681, 32711,
41
+ 32740, 32770, 32799, 32829, 32858, 32888, 32917, 32947, 32976, 33006, 33035, 33065, 33094, 33124, 33153, 33183, 33213, 33243, 33272, 33302,
42
+ 33331, 33361, 33390, 33420, 33450, 33479, 33509, 33539, 33568, 33598, 33627, 33657, 33686, 33716, 33745, 33775, 33804, 33834, 33863, 33893,
43
+ 33922, 33952, 33981, 34011, 34040, 34069, 34099, 34128, 34158, 34187, 34217, 34247, 34277, 34306, 34336, 34365, 34395, 34424, 34454, 34483,
44
+ 34512, 34542, 34571, 34601, 34631, 34660, 34690, 34719, 34749, 34778, 34808, 34837, 34867, 34896, 34926, 34955, 34985, 35015, 35044, 35074,
45
+ 35103, 35133, 35162, 35192, 35222, 35251, 35280, 35310, 35340, 35370, 35399, 35429, 35458, 35488, 35517, 35547, 35576, 35605, 35635, 35665,
46
+ 35694, 35723, 35753, 35782, 35811, 35841, 35871, 35901, 35930, 35960, 35989, 36019, 36048, 36078, 36107, 36136, 36166, 36195, 36225, 36254,
47
+ 36284, 36314, 36343, 36373, 36403, 36433, 36462, 36492, 36521, 36551, 36580, 36610, 36639, 36669, 36698, 36728, 36757, 36786, 36816, 36845,
48
+ 36875, 36904, 36934, 36963, 36993, 37022, 37052, 37081, 37111, 37141, 37170, 37200, 37229, 37259, 37288, 37318, 37347, 37377, 37406, 37436,
49
+ 37465, 37495, 37524, 37554, 37584, 37613, 37643, 37672, 37701, 37731, 37760, 37790, 37819, 37849, 37878, 37908, 37938, 37967, 37997, 38027,
50
+ 38056, 38085, 38115, 38144, 38174, 38203, 38233, 38262, 38292, 38322, 38351, 38381, 38410, 38440, 38469, 38499, 38528, 38558, 38587, 38617,
51
+ 38646, 38676, 38705, 38735, 38764, 38794, 38823, 38853, 38882, 38912, 38941, 38971, 39001, 39030, 39059, 39089, 39118, 39148, 39178, 39208,
52
+ 39237, 39267, 39297, 39326, 39355, 39385, 39414, 39444, 39473, 39503, 39532, 39562, 39592, 39621, 39650, 39680, 39709, 39739, 39768, 39798,
53
+ 39827, 39857, 39886, 39916, 39946, 39975, 40005, 40035, 40064, 40094, 40123, 40153, 40182, 40212, 40241, 40271, 40300, 40330, 40359, 40389,
54
+ 40418, 40448, 40477, 40507, 40536, 40566, 40595, 40625, 40655, 40685, 40714, 40744, 40773, 40803, 40832, 40862, 40892, 40921, 40951, 40980,
55
+ 41009, 41039, 41068, 41098, 41127, 41157, 41186, 41216, 41245, 41275, 41304, 41334, 41364, 41393, 41422, 41452, 41481, 41511, 41540, 41570,
56
+ 41599, 41629, 41658, 41688, 41718, 41748, 41777, 41807, 41836, 41865, 41894, 41924, 41953, 41983, 42012, 42042, 42072, 42102, 42131, 42161,
57
+ 42190, 42220, 42249, 42279, 42308, 42337, 42367, 42397, 42426, 42456, 42485, 42515, 42545, 42574, 42604, 42633, 42662, 42692, 42721, 42751,
58
+ 42780, 42810, 42839, 42869, 42899, 42929, 42958, 42988, 43017, 43046, 43076, 43105, 43135, 43164, 43194, 43223, 43253, 43283, 43312, 43342,
59
+ 43371, 43401, 43430, 43460, 43489, 43519, 43548, 43578, 43607, 43637, 43666, 43696, 43726, 43755, 43785, 43814, 43844, 43873, 43903, 43932,
60
+ 43962, 43991, 44021, 44050, 44080, 44109, 44139, 44169, 44198, 44228, 44258, 44287, 44317, 44346, 44375, 44405, 44434, 44464, 44493, 44523,
61
+ 44553, 44582, 44612, 44641, 44671, 44700, 44730, 44759, 44788, 44818, 44847, 44877, 44906, 44936, 44966, 44996, 45025, 45055, 45084, 45114,
62
+ 45143, 45172, 45202, 45231, 45261, 45290, 45320, 45350, 45380, 45409, 45439, 45468, 45498, 45527, 45556, 45586, 45615, 45644, 45674, 45704,
63
+ 45733, 45763, 45793, 45823, 45852, 45882, 45911, 45940, 45970, 45999, 46028, 46058, 46088, 46117, 46147, 46177, 46206, 46236, 46265, 46295,
64
+ 46324, 46354, 46383, 46413, 46442, 46472, 46501, 46531, 46560, 46590, 46620, 46649, 46679, 46708, 46738, 46767, 46797, 46826, 46856, 46885,
65
+ 46915, 46944, 46974, 47003, 47033, 47063, 47092, 47122, 47151, 47181, 47210, 47240, 47269, 47298, 47328, 47357, 47387, 47417, 47446, 47476,
66
+ 47506, 47535, 47565, 47594, 47624, 47653, 47682, 47712, 47741, 47771, 47800, 47830, 47860, 47890, 47919, 47949, 47978, 48008, 48037, 48066,
67
+ 48096, 48125, 48155, 48184, 48214, 48244, 48273, 48303, 48333, 48362, 48392, 48421, 48450, 48480, 48509, 48538, 48568, 48598, 48627, 48657,
68
+ 48687, 48717, 48746, 48776, 48805, 48834, 48864, 48893, 48922, 48952, 48982, 49011, 49041, 49071, 49100, 49130, 49160, 49189, 49218, 49248,
69
+ 49277, 49306, 49336, 49365, 49395, 49425, 49455, 49484, 49514, 49543, 49573, 49602, 49632, 49661, 49690, 49720, 49749, 49779, 49809, 49838,
70
+ 49868, 49898, 49927, 49957, 49986, 50016, 50045, 50075, 50104, 50133, 50163, 50192, 50222, 50252, 50281, 50311, 50340, 50370, 50400, 50429,
71
+ 50459, 50488, 50518, 50547, 50576, 50606, 50635, 50665, 50694, 50724, 50754, 50784, 50813, 50843, 50872, 50902, 50931, 50960, 50990, 51019,
72
+ 51049, 51078, 51108, 51138, 51167, 51197, 51227, 51256, 51286, 51315, 51345, 51374, 51403, 51433, 51462, 51492, 51522, 51552, 51582, 51611,
73
+ 51641, 51670, 51699, 51729, 51758, 51787, 51816, 51846, 51876, 51906, 51936, 51965, 51995, 52025, 52054, 52083, 52113, 52142, 52171, 52200,
74
+ 52230, 52260, 52290, 52319, 52349, 52379, 52408, 52438, 52467, 52497, 52526, 52555, 52585, 52614, 52644, 52673, 52703, 52733, 52762, 52792,
75
+ 52822, 52851, 52881, 52910, 52939, 52969, 52998, 53028, 53057, 53087, 53116, 53146, 53176, 53205, 53235, 53264, 53294, 53324, 53353, 53383,
76
+ 53412, 53441, 53471, 53500, 53530, 53559, 53589, 53619, 53648, 53678, 53708, 53737, 53767, 53796, 53825, 53855, 53884, 53913, 53943, 53973,
77
+ 54003, 54032, 54062, 54092, 54121, 54151, 54180, 54209, 54239, 54268, 54297, 54327, 54357, 54387, 54416, 54446, 54476, 54505, 54535, 54564,
78
+ 54593, 54623, 54652, 54681, 54711, 54741, 54770, 54800, 54830, 54859, 54889, 54919, 54948, 54977, 55007, 55036, 55066, 55095, 55125, 55154,
79
+ 55184, 55213, 55243, 55273, 55302, 55332, 55361, 55391, 55420, 55450, 55479, 55508, 55538, 55567, 55597, 55627, 55657, 55686, 55716, 55745,
80
+ 55775, 55804, 55834, 55863, 55892, 55922, 55951, 55981, 56011, 56040, 56070, 56100, 56129, 56159, 56188, 56218, 56247, 56276, 56306, 56335,
81
+ 56365, 56394, 56424, 56454, 56483, 56513, 56543, 56572, 56601, 56631, 56660, 56690, 56719, 56749, 56778, 56808, 56837, 56867, 56897, 56926,
82
+ 56956, 56985, 57015, 57044, 57074, 57103, 57133, 57162, 57192, 57221, 57251, 57280, 57310, 57340, 57369, 57399, 57429, 57458, 57487, 57517,
83
+ 57546, 57576, 57605, 57634, 57664, 57694, 57723, 57753, 57783, 57813, 57842, 57871, 57901, 57930, 57959, 57989, 58018, 58048, 58077, 58107,
84
+ 58137, 58167, 58196, 58226, 58255, 58285, 58314, 58343, 58373, 58402, 58432, 58461, 58491, 58521, 58551, 58580, 58610, 58639, 58669, 58698,
85
+ 58727, 58757, 58786, 58816, 58845, 58875, 58905, 58934, 58964, 58994, 59023, 59053, 59082, 59111, 59141, 59170, 59200, 59229, 59259, 59288,
86
+ 59318, 59348, 59377, 59407, 59436, 59466, 59495, 59525, 59554, 59584, 59613, 59643, 59672, 59702, 59731, 59761, 59791, 59820, 59850, 59879,
87
+ 59909, 59939, 59968, 59997, 60027, 60056, 60086, 60115, 60145, 60174, 60204, 60234, 60264, 60293, 60323, 60352, 60381, 60411, 60440, 60469,
88
+ 60499, 60528, 60558, 60588, 60618, 60648, 60677, 60707, 60736, 60765, 60795, 60824, 60853, 60883, 60912, 60942, 60972, 61002, 61031, 61061,
89
+ 61090, 61120, 61149, 61179, 61208, 61237, 61267, 61296, 61326, 61356, 61385, 61415, 61445, 61474, 61504, 61533, 61563, 61592, 61621, 61651,
90
+ 61680, 61710, 61739, 61769, 61799, 61828, 61858, 61888, 61917, 61947, 61976, 62006, 62035, 62064, 62094, 62123, 62153, 62182, 62212, 62242,
91
+ 62271, 62301, 62331, 62360, 62390, 62419, 62448, 62478, 62507, 62537, 62566, 62596, 62625, 62655, 62685, 62715, 62744, 62774, 62803, 62832,
92
+ 62862, 62891, 62921, 62950, 62980, 63009, 63039, 63069, 63099, 63128, 63157, 63187, 63216, 63246, 63275, 63305, 63334, 63363, 63393, 63423,
93
+ 63453, 63482, 63512, 63541, 63571, 63600, 63630, 63659, 63689, 63718, 63747, 63777, 63807, 63836, 63866, 63895, 63925, 63955, 63984, 64014,
94
+ 64043, 64073, 64102, 64131, 64161, 64190, 64220, 64249, 64279, 64309, 64339, 64368, 64398, 64427, 64457, 64486, 64515, 64545, 64574, 64603,
95
+ 64633, 64663, 64692, 64722, 64752, 64782, 64811, 64841, 64870, 64899, 64929, 64958, 64987, 65017, 65047, 65076, 65106, 65136, 65166, 65195,
96
+ 65225, 65254, 65283, 65313, 65342, 65371, 65401, 65431, 65460, 65490, 65520, 65549, 65579, 65608, 65638, 65667, 65697, 65726, 65755, 65785,
97
+ 65815, 65844, 65874, 65903, 65933, 65963, 65992, 66022, 66051, 66081, 66110, 66140, 66169, 66199, 66228, 66258, 66287, 66317, 66346, 66376,
98
+ 66405, 66435, 66465, 66494, 66524, 66553, 66583, 66612, 66641, 66671, 66700, 66730, 66760, 66789, 66819, 66849, 66878, 66908, 66937, 66967,
99
+ 66996, 67025, 67055, 67084, 67114, 67143, 67173, 67203, 67233, 67262, 67292, 67321, 67351, 67380, 67409, 67439, 67468, 67497, 67527, 67557,
100
+ 67587, 67617, 67646, 67676, 67705, 67735, 67764, 67793, 67823, 67852, 67882, 67911, 67941, 67971, 68000, 68030, 68060, 68089, 68119, 68148,
101
+ 68177, 68207, 68236, 68266, 68295, 68325, 68354, 68384, 68414, 68443, 68473, 68502, 68532, 68561, 68591, 68620, 68650, 68679, 68708, 68738,
102
+ 68768, 68797, 68827, 68857, 68886, 68916, 68946, 68975, 69004, 69034, 69063, 69092, 69122, 69152, 69181, 69211, 69240, 69270, 69300, 69330,
103
+ 69359, 69388, 69418, 69447, 69476, 69506, 69535, 69565, 69595, 69624, 69654, 69684, 69713, 69743, 69772, 69802, 69831, 69861, 69890, 69919,
104
+ 69949, 69978, 70008, 70038, 70067, 70097, 70126, 70156, 70186, 70215, 70245, 70274, 70303, 70333, 70362, 70392, 70421, 70451, 70481, 70510,
105
+ 70540, 70570, 70599, 70629, 70658, 70687, 70717, 70746, 70776, 70805, 70835, 70864, 70894, 70924, 70954, 70983, 71013, 71042, 71071, 71101,
106
+ 71130, 71159, 71189, 71218, 71248, 71278, 71308, 71337, 71367, 71397, 71426, 71455, 71485, 71514, 71543, 71573, 71602, 71632, 71662, 71691,
107
+ 71721, 71751, 71781, 71810, 71839, 71869, 71898, 71927, 71957, 71986, 72016, 72046, 72075, 72105, 72135, 72164, 72194, 72223, 72253, 72282,
108
+ 72311, 72341, 72370, 72400, 72429, 72459, 72489, 72518, 72548, 72577, 72607, 72637, 72666, 72695, 72725, 72754, 72784, 72813, 72843, 72872,
109
+ 72902, 72931, 72961, 72991, 73020, 73050, 73080, 73109, 73139, 73168, 73197, 73227, 73256, 73286, 73315, 73345, 73375, 73404, 73434, 73464,
110
+ 73493, 73523, 73552, 73581, 73611, 73640, 73669, 73699, 73729, 73758, 73788, 73818, 73848, 73877, 73907, 73936, 73965, 73995, 74024, 74053,
111
+ 74083, 74113, 74142, 74172, 74202, 74231, 74261, 74291, 74320, 74349, 74379, 74408, 74437, 74467, 74497, 74526, 74556, 74586, 74615, 74645,
112
+ 74675, 74704, 74733, 74763, 74792, 74822, 74851, 74881, 74910, 74940, 74969, 74999, 75029, 75058, 75088, 75117, 75147, 75176, 75206, 75235,
113
+ 75264, 75294, 75323, 75353, 75383, 75412, 75442, 75472, 75501, 75531, 75560, 75590, 75619, 75648, 75678, 75707, 75737, 75766, 75796, 75826,
114
+ 75856, 75885, 75915, 75944, 75974, 76003, 76032, 76062, 76091, 76121, 76150, 76180, 76210, 76239, 76269, 76299, 76328, 76358, 76387, 76416,
115
+ 76446, 76475, 76505, 76534, 76564, 76593, 76623, 76653, 76682, 76712, 76741, 76771, 76801, 76830, 76859, 76889, 76918, 76948, 76977, 77007,
116
+ 77036, 77066, 77096, 77125, 77155, 77185, 77214, 77243, 77273, 77302, 77332, 77361, 77390, 77420, 77450, 77479, 77509, 77539, 77569, 77598,
117
+ 77627, 77657, 77686, 77715, 77745, 77774, 77804, 77833, 77863, 77893, 77923, 77952, 77982, 78011, 78041, 78070, 78099, 78129, 78158, 78188,
118
+ 78217, 78247, 78277, 78307, 78336, 78366, 78395, 78425, 78454, 78483, 78513, 78542, 78572, 78601, 78631, 78661, 78690, 78720, 78750, 78779,
119
+ 78808, 78838, 78867, 78897, 78926, 78956, 78985, 79015, 79044, 79074, 79104, 79133, 79163, 79192, 79222, 79251, 79281, 79310, 79340, 79369,
120
+ 79399, 79428, 79458, 79487, 79517, 79546, 79576, 79606, 79635, 79665, 79695, 79724, 79753, 79783, 79812, 79841, 79871, 79900, 79930, 79960,
121
+ 79990]
122
+ }
123
+
124
+ var formattingTokens = /(\[[^\[]*\])|(\\)?i(Mo|MM?M?M?|Do|DDDo|DD?D?D?|w[o|w]?|YYYYY|YYYY|YY|gg(ggg?)?)|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,
125
+ localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g
126
+
127
+ , parseTokenOneOrTwoDigits = /\d\d?/, parseTokenOneToThreeDigits = /\d{1,3}/, parseTokenThreeDigits = /\d{3}/, parseTokenFourDigits = /\d{1,4}/, parseTokenSixDigits = /[+\-]?\d{1,6}/, parseTokenWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.?)|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i, parseTokenTimezone = /Z|[\+\-]\d\d:?\d\d/i, parseTokenT = /T/i, parseTokenTimestampMs = /[\+\-]?\d+(\.\d{1,3})?/
128
+
129
+ , unitAliases = {
130
+ hd: 'idate',
131
+ hm: 'imonth',
132
+ hy: 'iyear'
133
+ }
134
+
135
+ , formatFunctions = {}
136
+
137
+ , ordinalizeTokens = 'DDD w M D'.split(' '), paddedTokens = 'M D w'.split(' ')
138
+
139
+ , formatTokenFunctions = {
140
+ iM: function () {
141
+ return this.iMonth() + 1
142
+ },
143
+ iMMM: function (format) {
144
+ return this.localeData().iMonthsShort(this, format)
145
+ },
146
+ iMMMM: function (format) {
147
+ return this.localeData().iMonths(this, format)
148
+ },
149
+ iD: function () {
150
+ return this.iDate()
151
+ },
152
+ iDDD: function () {
153
+ return this.iDayOfYear()
154
+ },
155
+ iw: function () {
156
+ return this.iWeek()
157
+ },
158
+ iYY: function () {
159
+ return leftZeroFill(this.iYear() % 100, 2)
160
+ },
161
+ iYYYY: function () {
162
+ return leftZeroFill(this.iYear(), 4)
163
+ },
164
+ iYYYYY: function () {
165
+ return leftZeroFill(this.iYear(), 5)
166
+ },
167
+ igg: function () {
168
+ return leftZeroFill(this.iWeekYear() % 100, 2)
169
+ },
170
+ igggg: function () {
171
+ return this.iWeekYear()
172
+ },
173
+ iggggg: function () {
174
+ return leftZeroFill(this.iWeekYear(), 5)
175
+ }
176
+ }, i
177
+
178
+ function padToken(func, count) {
179
+ return function (a) {
180
+ return leftZeroFill(func.call(this, a), count)
181
+ }
182
+ }
183
+
184
+ function ordinalizeToken(func, period) {
185
+ return function (a) {
186
+ return this.localeData().ordinal(func.call(this, a), period)
187
+ }
188
+ }
189
+
190
+ while (ordinalizeTokens.length) {
191
+ i = ordinalizeTokens.pop()
192
+ formatTokenFunctions['i' + i + 'o'] = ordinalizeToken(formatTokenFunctions['i' + i], i)
193
+ }
194
+ while (paddedTokens.length) {
195
+ i = paddedTokens.pop()
196
+ formatTokenFunctions['i' + i + i] = padToken(formatTokenFunctions['i' + i], 2)
197
+ }
198
+ formatTokenFunctions.iDDDD = padToken(formatTokenFunctions.iDDD, 3)
199
+
200
+ /************************************
201
+ Helpers
202
+ ************************************/
203
+
204
+ function extend(a, b) {
205
+ var key
206
+ for (key in b)
207
+ if (b.hasOwnProperty(key))
208
+ a[key] = b[key]
209
+ return a
210
+ }
211
+
212
+ function leftZeroFill(number, targetLength) {
213
+ var output = number + ''
214
+ while (output.length < targetLength)
215
+ output = '0' + output
216
+ return output
217
+ }
218
+
219
+ function isArray(input) {
220
+ return Object.prototype.toString.call(input) === '[object Array]'
221
+ }
222
+
223
+ function normalizeUnits(units) {
224
+ return units ? unitAliases[units] || units.toLowerCase().replace(/(.)s$/, '$1') : units
225
+ }
226
+
227
+ function setDate(moment, year, month, date) {
228
+ var utc = moment._isUTC ? 'UTC' : ''
229
+ moment._d['set' + utc + 'FullYear'](year)
230
+ moment._d['set' + utc + 'Month'](month)
231
+ moment._d['set' + utc + 'Date'](date)
232
+ }
233
+
234
+ function objectCreate(parent) {
235
+ function F() {}
236
+ F.prototype = parent
237
+ return new F()
238
+ }
239
+
240
+ function getPrototypeOf(object) {
241
+ if (Object.getPrototypeOf)
242
+ return Object.getPrototypeOf(object)
243
+ else if (''.__proto__) // jshint ignore:line
244
+ return object.__proto__ // jshint ignore:line
245
+ else
246
+ return object.constructor.prototype
247
+ }
248
+
249
+ /************************************
250
+ Languages
251
+ ************************************/
252
+ extend(getPrototypeOf(moment.localeData()), {
253
+ _iMonths: ['Muharram'
254
+ , 'Safar'
255
+ , 'Rabi\' al-Awwal'
256
+ , 'Rabi\' al-Thani'
257
+ , 'Jumada al-Ula'
258
+ , 'Jumada al-Alkhirah'
259
+ , 'Rajab'
260
+ , 'Sha’ban'
261
+ , 'Ramadhan'
262
+ , 'Shawwal'
263
+ , 'Thul-Qi’dah'
264
+ , 'Thul-Hijjah'
265
+ ],
266
+ iMonths: function (m) {
267
+ return this._iMonths[m.iMonth()]
268
+ }
269
+
270
+ ,
271
+ _iMonthsShort: ['Muh'
272
+ , 'Saf'
273
+ , 'Rab-I'
274
+ , 'Rab-II'
275
+ , 'Jum-I'
276
+ , 'Jum-II'
277
+ , 'Raj'
278
+ , 'Sha'
279
+ , 'Ram'
280
+ , 'Shw'
281
+ , 'Dhu-Q'
282
+ , 'Dhu-H'
283
+ ],
284
+ iMonthsShort: function (m) {
285
+ return this._iMonthsShort[m.iMonth()]
286
+ }
287
+
288
+ ,
289
+ iMonthsParse: function (monthName) {
290
+ var i, mom, regex
291
+ if (!this._iMonthsParse)
292
+ this._iMonthsParse = []
293
+ for (i = 0; i < 12; i += 1) {
294
+ // Make the regex if we don't have it already.
295
+ if (!this._iMonthsParse[i]) {
296
+ mom = hMoment([2000, (2 + i) % 12, 25])
297
+ regex = '^' + this.iMonths(mom, '') + '$|^' + this.iMonthsShort(mom, '') + '$'
298
+ this._iMonthsParse[i] = new RegExp(regex.replace('.', ''), 'i')
299
+ }
300
+ // Test the regex.
301
+ if (this._iMonthsParse[i].test(monthName))
302
+ return i
303
+ }
304
+ }
305
+ });
306
+ var iMonthNames = {
307
+ iMonths: 'محرم_صفر_ربيع الأول_ربيع الثاني_جمادى الأولى_جمادى الآخرة_رجب_شعبان_رمضان_شوال_ذو القعدة_ذو الحجة'.split('_'),
308
+ iMonthsShort: 'محرم_صفر_ربيع ١_ربيع ٢_جمادى ١_جمادى ٢_رجب_شعبان_رمضان_شوال_ذو القعدة_ذو الحجة'.split('_')
309
+ };
310
+
311
+ // Default to the momentjs 2.12+ API
312
+ if (typeof moment.updateLocale === 'function') {
313
+ moment.updateLocale('ar-sa', iMonthNames);
314
+ } else {
315
+ var oldLocale = moment.locale();
316
+ moment.defineLocale('ar-sa', iMonthNames);
317
+ moment.locale(oldLocale);
318
+ }
319
+
320
+ /************************************
321
+ Formatting
322
+ ************************************/
323
+
324
+ function makeFormatFunction(format) {
325
+ var array = format.match(formattingTokens),
326
+ length = array.length,
327
+ i
328
+
329
+ for (i = 0; i < length; i += 1)
330
+ if (formatTokenFunctions[array[i]])
331
+ array[i] = formatTokenFunctions[array[i]]
332
+
333
+ return function (mom) {
334
+ var output = ''
335
+ for (i = 0; i < length; i += 1)
336
+ output += array[i] instanceof Function ? '[' + array[i].call(mom, format) + ']' : array[i]
337
+ return output
338
+ }
339
+ }
340
+
341
+ /************************************
342
+ Parsing
343
+ ************************************/
344
+
345
+ function getParseRegexForToken(token, config) {
346
+ switch (token) {
347
+ case 'iDDDD':
348
+ return parseTokenThreeDigits
349
+ case 'iYYYY':
350
+ return parseTokenFourDigits
351
+ case 'iYYYYY':
352
+ return parseTokenSixDigits
353
+ case 'iDDD':
354
+ return parseTokenOneToThreeDigits
355
+ case 'iMMM':
356
+ case 'iMMMM':
357
+ return parseTokenWord
358
+ case 'iMM':
359
+ case 'iDD':
360
+ case 'iYY':
361
+ case 'iM':
362
+ case 'iD':
363
+ return parseTokenOneOrTwoDigits
364
+ case 'DDDD':
365
+ return parseTokenThreeDigits
366
+ case 'YYYY':
367
+ return parseTokenFourDigits
368
+ case 'YYYYY':
369
+ return parseTokenSixDigits
370
+ case 'S':
371
+ case 'SS':
372
+ case 'SSS':
373
+ case 'DDD':
374
+ return parseTokenOneToThreeDigits
375
+ case 'MMM':
376
+ case 'MMMM':
377
+ case 'dd':
378
+ case 'ddd':
379
+ case 'dddd':
380
+ return parseTokenWord
381
+ case 'a':
382
+ case 'A':
383
+ return moment.localeData(config._l)._meridiemParse
384
+ case 'X':
385
+ return parseTokenTimestampMs
386
+ case 'Z':
387
+ case 'ZZ':
388
+ return parseTokenTimezone
389
+ case 'T':
390
+ return parseTokenT
391
+ case 'MM':
392
+ case 'DD':
393
+ case 'YY':
394
+ case 'HH':
395
+ case 'hh':
396
+ case 'mm':
397
+ case 'ss':
398
+ case 'M':
399
+ case 'D':
400
+ case 'd':
401
+ case 'H':
402
+ case 'h':
403
+ case 'm':
404
+ case 's':
405
+ return parseTokenOneOrTwoDigits
406
+ default:
407
+ return new RegExp(token.replace('\\', ''))
408
+ }
409
+ }
410
+
411
+ function addTimeToArrayFromToken(token, input, config) {
412
+ var a, datePartArray = config._a
413
+
414
+ switch (token) {
415
+ case 'iM':
416
+ case 'iMM':
417
+ datePartArray[1] = input == null ? 0 : ~~input - 1
418
+ break
419
+ case 'iMMM':
420
+ case 'iMMMM':
421
+ a = moment.localeData(config._l).iMonthsParse(input)
422
+ if (a != null)
423
+ datePartArray[1] = a
424
+ else
425
+ config._isValid = !1
426
+ break
427
+ case 'iD':
428
+ case 'iDD':
429
+ case 'iDDD':
430
+ case 'iDDDD':
431
+ if (input != null)
432
+ datePartArray[2] = ~~input
433
+ break
434
+ case 'iYY':
435
+ datePartArray[0] = ~~input + (~~input > 47 ? 1300 : 1400)
436
+ break
437
+ case 'iYYYY':
438
+ case 'iYYYYY':
439
+ datePartArray[0] = ~~input
440
+ }
441
+ if (input == null)
442
+ config._isValid = !1
443
+ }
444
+
445
+ function dateFromArray(config) {
446
+ var g, h, hy = config._a[0],
447
+ hm = config._a[1],
448
+ hd = config._a[2]
449
+
450
+ if ((hy == null) && (hm == null) && (hd == null))
451
+ return [0, 0, 1]
452
+ hy = hy || 0
453
+ hm = hm || 0
454
+ hd = hd || 1
455
+ if (hd < 1 || hd > hMoment.iDaysInMonth(hy, hm))
456
+ config._isValid = !1
457
+ g = toGregorian(hy, hm, hd)
458
+ h = toHijri(g.gy, g.gm, g.gd)
459
+ config._hDiff = 0
460
+ if (~~h.hy !== hy)
461
+ config._hDiff += 1
462
+ if (~~h.hm !== hm)
463
+ config._hDiff += 1
464
+ if (~~h.hd !== hd)
465
+ config._hDiff += 1
466
+ return [g.gy, g.gm, g.gd]
467
+ }
468
+
469
+ function makeDateFromStringAndFormat(config) {
470
+ var tokens = config._f.match(formattingTokens),
471
+ string = config._i,
472
+ len = tokens.length,
473
+ i, token, parsedInput
474
+
475
+ config._a = []
476
+
477
+ for (i = 0; i < len; i += 1) {
478
+ token = tokens[i]
479
+ parsedInput = (getParseRegexForToken(token, config).exec(string) || [])[0];
480
+ if (parsedInput)
481
+ string = string.slice(string.indexOf(parsedInput) + parsedInput.length)
482
+ if (formatTokenFunctions[token])
483
+ addTimeToArrayFromToken(token, parsedInput, config)
484
+ }
485
+ if (string)
486
+ config._il = string
487
+
488
+ return dateFromArray(config)
489
+ }
490
+
491
+ function makeDateFromStringAndArray(config, utc) {
492
+ var len = config._f.length
493
+ , i
494
+ , format
495
+ , tempMoment
496
+ , bestMoment
497
+ , currentScore
498
+ , scoreToBeat
499
+
500
+ if (len === 0) {
501
+ return makeMoment(new Date(NaN))
502
+ }
503
+
504
+ for (i = 0; i < len; i += 1) {
505
+ format = config._f[i]
506
+ currentScore = 0
507
+ tempMoment = makeMoment(config._i, format, config._l, utc)
508
+
509
+ if (!tempMoment.isValid()) continue
510
+
511
+ currentScore += tempMoment._hDiff
512
+ if (tempMoment._il)
513
+ currentScore += tempMoment._il.length
514
+ if (scoreToBeat == null || currentScore < scoreToBeat) {
515
+ scoreToBeat = currentScore
516
+ bestMoment = tempMoment
517
+ }
518
+ }
519
+
520
+ return bestMoment
521
+ }
522
+
523
+ function removeParsedTokens(config) {
524
+ var string = config._i,
525
+ input = '',
526
+ format = '',
527
+ array = config._f.match(formattingTokens),
528
+ len = array.length,
529
+ i, match, parsed
530
+
531
+ for (i = 0; i < len; i += 1) {
532
+ match = array[i]
533
+ parsed = (getParseRegexForToken(match, config).exec(string) || [])[0]
534
+ if (parsed)
535
+ string = string.slice(string.indexOf(parsed) + parsed.length)
536
+ if (!(formatTokenFunctions[match] instanceof Function)) {
537
+ format += match
538
+ if (parsed)
539
+ input += parsed
540
+ }
541
+ }
542
+ config._i = input
543
+ config._f = format
544
+ }
545
+
546
+ /************************************
547
+ Week of Year
548
+ ************************************/
549
+
550
+ function iWeekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
551
+ var end = firstDayOfWeekOfYear - firstDayOfWeek,
552
+ daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
553
+ adjustedMoment
554
+
555
+ if (daysToDayOfWeek > end) {
556
+ daysToDayOfWeek -= 7
557
+ }
558
+ if (daysToDayOfWeek < end - 7) {
559
+ daysToDayOfWeek += 7
560
+ }
561
+ adjustedMoment = hMoment(mom).add(daysToDayOfWeek, 'd')
562
+ return {
563
+ week: Math.ceil(adjustedMoment.iDayOfYear() / 7),
564
+ year: adjustedMoment.iYear()
565
+ }
566
+ }
567
+
568
+ /************************************
569
+ Top Level Functions
570
+ ************************************/
571
+
572
+ function makeMoment(input, format, lang, utc) {
573
+ var config =
574
+ { _i: input
575
+ , _f: format
576
+ , _l: lang
577
+ }
578
+ , date
579
+ , m
580
+ , hm
581
+ if (format) {
582
+ if (isArray(format)) {
583
+ return makeDateFromStringAndArray(config, utc)
584
+ } else {
585
+ date = makeDateFromStringAndFormat(config)
586
+ removeParsedTokens(config)
587
+ format = 'YYYY-MM-DD-' + config._f
588
+ input = leftZeroFill(date[0], 4) + '-'
589
+ + leftZeroFill(date[1] + 1, 2) + '-'
590
+ + leftZeroFill(date[2], 2) + '-'
591
+ + config._i
592
+ }
593
+ }
594
+ if (utc)
595
+ m = moment.utc(input, format, lang)
596
+ else
597
+ m = moment(input, format, lang)
598
+ if (config._isValid === !1)
599
+ m._isValid = !1
600
+ m._hDiff = config._hDiff || 0
601
+ hm = objectCreate(hMoment.fn)
602
+ extend(hm, m)
603
+ return hm
604
+ }
605
+
606
+ function hMoment(input, format, lang) {
607
+ return makeMoment(input, format, lang, !1)
608
+ }
609
+
610
+ extend(hMoment, moment)
611
+ hMoment.fn = objectCreate(moment.fn)
612
+
613
+ hMoment.utc = function (input, format, lang) {
614
+ return makeMoment(input, format, lang, !0)
615
+ }
616
+
617
+ /************************************
618
+ hMoment Prototype
619
+ ************************************/
620
+
621
+ hMoment.fn.format = function (format) {
622
+ var i, replace, me = this
623
+
624
+ if (format) {
625
+ i = 5
626
+ replace = function (input) {
627
+ return me.localeData().longDateFormat(input) || input
628
+ }
629
+ while (i > 0 && localFormattingTokens.test(format)) {
630
+ i -= 1
631
+ format = format.replace(localFormattingTokens, replace)
632
+ }
633
+ if (!formatFunctions[format]) {
634
+ formatFunctions[format] = makeFormatFunction(format)
635
+ }
636
+ format = formatFunctions[format](this)
637
+ }
638
+ return moment.fn.format.call(this, format)
639
+ }
640
+
641
+ hMoment.fn.iYear = function (input) {
642
+ var lastDay, h, g
643
+ if (typeof input === 'number') {
644
+ h = toHijri(this.year(), this.month(), this.date())
645
+ lastDay = Math.min(h.hd, hMoment.iDaysInMonth(input, h.hm))
646
+ g = toGregorian(input, h.hm, lastDay)
647
+ setDate(this, g.gy, g.gm, g.gd)
648
+ //Workaround: sometimes moment wont set the date correctly if current day is the last in the month
649
+ if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
650
+ setDate(this, g.gy, g.gm, g.gd)
651
+ }
652
+ moment.updateOffset(this)
653
+ return this
654
+ } else {
655
+ return toHijri(this.year(), this.month(), this.date()).hy
656
+ }
657
+ }
658
+
659
+ hMoment.fn.iMonth = function (input) {
660
+ var lastDay, h, g
661
+ if (input != null) {
662
+ if (typeof input === 'string') {
663
+ input = this.localeData().iMonthsParse(input)
664
+ if(input >= 0) {
665
+ input -= 1
666
+ } else {
667
+ return this
668
+ }
669
+ }
670
+ h = toHijri(this.year(), this.month(), this.date())
671
+ lastDay = Math.min(h.hd, hMoment.iDaysInMonth(h.hy, input))
672
+ this.iYear(h.hy + div(input, 12))
673
+ input = mod(input, 12)
674
+ if (input < 0) {
675
+ input += 12
676
+ this.iYear(this.iYear() - 1)
677
+ }
678
+ g = toGregorian(this.iYear(), input, lastDay)
679
+ setDate(this, g.gy, g.gm, g.gd)
680
+ //Workaround: sometimes moment wont set the date correctly if current day is the last in the month
681
+ if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
682
+ setDate(this, g.gy, g.gm, g.gd)
683
+ }
684
+ moment.updateOffset(this)
685
+ return this
686
+ } else {
687
+ return toHijri(this.year(), this.month(), this.date()).hm
688
+ }
689
+ }
690
+
691
+ hMoment.fn.iDate = function (input) {
692
+ var h, g
693
+ if (typeof input === 'number') {
694
+ h = toHijri(this.year(), this.month(), this.date())
695
+ g = toGregorian(h.hy, h.hm, input)
696
+ setDate(this, g.gy, g.gm, g.gd)
697
+ //Workaround: sometimes moment wont set the date correctly if current day is the last in the month
698
+ if (this.month() !== g.gm || this.date() !== g.gd || this.year() !== g.gy) {
699
+ setDate(this, g.gy, g.gm, g.gd)
700
+ }
701
+ moment.updateOffset(this)
702
+ return this
703
+ } else {
704
+ return toHijri(this.year(), this.month(), this.date()).hd
705
+ }
706
+ }
707
+
708
+ hMoment.fn.iDayOfYear = function (input) {
709
+ var dayOfYear = Math.round((hMoment(this).startOf('day') - hMoment(this).startOf('iYear')) / 864e5) + 1
710
+ return input == null ? dayOfYear : this.add(input - dayOfYear, 'd')
711
+ }
712
+
713
+ hMoment.fn.iDaysInMonth = function () {
714
+ return parseInt(hMoment(this).endOf('iMonth').format('iDD'));
715
+ }
716
+
717
+ hMoment.fn.iWeek = function (input) {
718
+ var week = iWeekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).week
719
+ return input == null ? week : this.add( (input - week) * 7, 'd')
720
+ }
721
+
722
+ hMoment.fn.iWeekYear = function (input) {
723
+ var year = iWeekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year
724
+ return input == null ? year : this.add(input - year, 'y')
725
+ }
726
+
727
+ hMoment.fn.add = function (val, units) {
728
+ var temp
729
+ if (units !== null && !isNaN(+units)) {
730
+ temp = val
731
+ val = units
732
+ units = temp
733
+ }
734
+ units = normalizeUnits(units)
735
+ if (units === 'iyear') {
736
+ this.iYear(this.iYear() + val)
737
+ } else if (units === 'imonth') {
738
+ this.iMonth(this.iMonth() + val)
739
+ } else if (units === 'idate') {
740
+ this.iDate(this.iDate() + val)
741
+ }
742
+ else {
743
+ moment.fn.add.call(this, val, units)
744
+ }
745
+ return this
746
+ }
747
+
748
+ hMoment.fn.subtract = function (val, units) {
749
+ var temp
750
+ if (units !== null && !isNaN(+units)) {
751
+ temp = val
752
+ val = units
753
+ units = temp
754
+ }
755
+ units = normalizeUnits(units)
756
+ if (units === 'iyear') {
757
+ this.iYear(this.iYear() - val)
758
+ } else if (units === 'imonth') {
759
+ this.iMonth(this.iMonth() - val)
760
+ } else if (units === 'idate') {
761
+ this.iDate(this.iDate() - val)
762
+ } else {
763
+ moment.fn.subtract.call(this, val, units)
764
+ }
765
+ return this
766
+ }
767
+
768
+ hMoment.fn.startOf = function (units) {
769
+ units = normalizeUnits(units)
770
+ if (units === 'iyear' || units === 'imonth') {
771
+ if (units === 'iyear') {
772
+ this.iMonth(0)
773
+ }
774
+ this.iDate(1)
775
+ this.hours(0)
776
+ this.minutes(0)
777
+ this.seconds(0)
778
+ this.milliseconds(0)
779
+ return this
780
+ } else {
781
+ return moment.fn.startOf.call(this, units)
782
+ }
783
+ }
784
+
785
+ hMoment.fn.endOf = function (units) {
786
+ units = normalizeUnits(units)
787
+ if (units === undefined || units === 'milisecond') {
788
+ return this
789
+ }
790
+ return this.startOf(units).add(1, (units === 'isoweek' ? 'week' : units)).subtract(1, 'milliseconds')
791
+ }
792
+
793
+ hMoment.fn.clone = function () {
794
+ return hMoment(this)
795
+ }
796
+
797
+ hMoment.fn.iYears = hMoment.fn.iYear
798
+ hMoment.fn.iMonths = hMoment.fn.iMonth
799
+ hMoment.fn.iDates = hMoment.fn.iDate
800
+ hMoment.fn.iWeeks = hMoment.fn.iWeek
801
+
802
+ /************************************
803
+ hMoment Statics
804
+ ************************************/
805
+
806
+ hMoment.iDaysInMonth = function (year, month) {
807
+ var i = getNewMoonMJDNIndex(year, month + 1),
808
+ daysInMonth = ummalqura.ummalquraData[i] - ummalqura.ummalquraData[i - 1]
809
+ return daysInMonth
810
+ }
811
+
812
+ function toHijri(gy, gm, gd) {
813
+ var h = d2h(g2d(gy, gm + 1, gd))
814
+ h.hm -= 1
815
+ return h
816
+ }
817
+
818
+ function toGregorian(hy, hm, hd) {
819
+ var g = d2g(h2d(hy, hm + 1, hd))
820
+ g.gm -= 1
821
+ return g
822
+ }
823
+
824
+ hMoment.iConvert = {
825
+ toHijri: toHijri,
826
+ toGregorian: toGregorian
827
+ }
828
+
829
+ return hMoment
830
+
831
+ /************************************
832
+ Hijri Conversion
833
+ ************************************/
834
+
835
+ /*
836
+ Utility helper functions.
837
+ */
838
+
839
+ function div(a, b) {
840
+ return~~ (a / b)
841
+ }
842
+
843
+ function mod(a, b) {
844
+ return a - ~~(a / b) * b
845
+ }
846
+
847
+ /*
848
+ Converts a date of the Hijri calendar to the Julian Day number.
849
+
850
+ @param hy Hijri year (1356 to 1500)
851
+ @param hm Hijri month (1 to 12)
852
+ @param hd Hijri day (1 to 29/30)
853
+ @return Julian Day number
854
+ */
855
+
856
+ function h2d(hy, hm, hd) {
857
+ var i = getNewMoonMJDNIndex(hy, hm),
858
+ mjdn = hd + ummalqura.ummalquraData[i - 1] - 1,
859
+ jdn = mjdn + 2400000;
860
+ return jdn
861
+ }
862
+
863
+ /*
864
+ Converts the Julian Day number to a date in the Hijri calendar.
865
+
866
+ @param jdn Julian Day number
867
+ @return
868
+ hy: Hijri year (1356 to 1500)
869
+ hm: Hijri month (1 to 12)
870
+ hd: Hijri day (1 to 29/30)
871
+ */
872
+
873
+ function d2h(jdn) {
874
+ var mjdn = jdn - 2400000,
875
+ i = getNewMoonMJDNIndexByJDN(mjdn),
876
+ totalMonths = i + 16260,
877
+ cYears = Math.floor((totalMonths - 1) / 12),
878
+ hy = cYears + 1,
879
+ hm = totalMonths - 12 * cYears,
880
+ hd = mjdn - ummalqura.ummalquraData[i - 1] + 1
881
+
882
+ return {
883
+ hy: hy,
884
+ hm: hm,
885
+ hd: hd
886
+ }
887
+ }
888
+
889
+ /*
890
+ Calculates the Julian Day number from Gregorian or Julian
891
+ calendar dates. This integer number corresponds to the noon of
892
+ the date (i.e. 12 hours of Universal Time).
893
+ The procedure was tested to be good since 1 March, -100100 (of both
894
+ calendars) up to a few million years into the future.
895
+
896
+ @param gy Calendar year (years BC numbered 0, -1, -2, ...)
897
+ @param gm Calendar month (1 to 12)
898
+ @param gd Calendar day of the month (1 to 28/29/30/31)
899
+ @return Julian Day number
900
+ */
901
+
902
+ function g2d(gy, gm, gd) {
903
+ var d = div((gy + div(gm - 8, 6) + 100100) * 1461, 4) + div(153 * mod(gm + 9, 12) + 2, 5) + gd - 34840408
904
+ d = d - div(div(gy + 100100 + div(gm - 8, 6), 100) * 3, 4) + 752
905
+ return d
906
+ }
907
+
908
+ /*
909
+ Calculates Gregorian and Julian calendar dates from the Julian Day number
910
+ (hdn) for the period since jdn=-34839655 (i.e. the year -100100 of both
911
+ calendars) to some millions years ahead of the present.
912
+
913
+ @param jdn Julian Day number
914
+ @return
915
+ gy: Calendar year (years BC numbered 0, -1, -2, ...)
916
+ gm: Calendar month (1 to 12)
917
+ gd: Calendar day of the month M (1 to 28/29/30/31)
918
+ */
919
+
920
+ function d2g(jdn) {
921
+ var j, i, gd, gm, gy
922
+ j = 4 * jdn + 139361631
923
+ j = j + div(div(4 * jdn + 183187720, 146097) * 3, 4) * 4 - 3908
924
+ i = div(mod(j, 1461), 4) * 5 + 308
925
+ gd = div(mod(i, 153), 5) + 1
926
+ gm = mod(div(i, 153), 12) + 1
927
+ gy = div(j, 1461) - 100100 + div(8 - gm, 6)
928
+ return {
929
+ gy: gy,
930
+ gm: gm,
931
+ gd: gd
932
+ }
933
+ }
934
+
935
+ /*
936
+ Returns the index of the modified Julian day number of the new moon
937
+ by the given year and month
938
+
939
+ @param hy: Hijri year (1356 to 1500)
940
+ @param hm: Hijri month (1 to 12)
941
+ @return
942
+ i: the index of the new moon in modified Julian day number.
943
+ */
944
+ function getNewMoonMJDNIndex(hy, hm) {
945
+ var cYears = hy - 1,
946
+ totalMonths = (cYears * 12) + 1 + (hm - 1),
947
+ i = totalMonths - 16260
948
+ return i
949
+ }
950
+
951
+ /*
952
+ Returns the nearest new moon
953
+
954
+ @param jdn Julian Day number
955
+ @return
956
+ i: the index of a modified Julian day number.
957
+ */
958
+ function getNewMoonMJDNIndexByJDN(mjdn) {
959
+ for (var i = 0; i < ummalqura.ummalquraData.length; i=i+1) {
960
+ if (ummalqura.ummalquraData[i] > mjdn)
961
+ return i
962
+ }
963
+ }
964
+
965
+ });