localBadiDate-msm-locales.mjs 106 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684
  1. /**
  2. * @license BadiDate v3.0.2
  3. * (c) 2018 Jan Greis
  4. * licensed under MIT
  5. */
  6. import { DateTime, Duration } from 'luxon';
  7. /**
  8. * @license MeeusSunMoon v3.0.0
  9. * (c) 2018 Jan Greis
  10. * licensed under MIT
  11. */
  12. /**
  13. * Converts angles in degrees to radians.
  14. * @param {number} deg Angle in degrees.
  15. * @returns {number} Angle in radians.
  16. */
  17. const deg2rad = (deg) => deg * 0.017453292519943295;
  18. /**
  19. * Converts angles in radians to degrees.
  20. * @param {number} rad Angle in radians.
  21. * @returns {number} Angle in degrees.
  22. */
  23. const rad2deg = (rad) => rad * 57.29577951308232;
  24. /**
  25. * Calculates the sine of an angle given in degrees.
  26. * @param {number} deg Angle in degrees.
  27. * @returns {number} Sine of the angle.
  28. */
  29. const sind = (deg) => Math.sin(deg2rad(deg));
  30. /**
  31. * Calculates the cosine of an angle given in degrees.
  32. * @param {number} deg Angle in degrees.
  33. * @returns {number} Cosine of the angle.
  34. */
  35. const cosd = (deg) => Math.cos(deg2rad(deg));
  36. /**
  37. * Reduces an angle to the interval 0-360°.
  38. * @param {number} angle Angle in degrees.
  39. * @returns {number} Reduced angle in degrees.
  40. */
  41. const reduceAngle = (angle) => angle - (360 * Math.floor(angle / 360));
  42. /**
  43. * Evaluates a polynomial in the form A + Bx + Cx^2...
  44. * @param {number} variable Value of x in the polynomial.
  45. * @param {array} coeffs Array of coefficients [A, B, C...].
  46. * @returns {number} Sum of the polynomial.
  47. */
  48. const polynomial = (variable, coeffs) => {
  49. let varPower = 1;
  50. let sum = 0.0;
  51. const numCoeffs = coeffs.length;
  52. for (let i = 0; i < numCoeffs; i++) {
  53. sum += varPower * coeffs[i];
  54. varPower *= variable;
  55. }
  56. return sum;
  57. };
  58. /**
  59. * Interpolates a value from 3 known values (see AA p24 Eq3.3).
  60. * @param {number} y1 Start value of the interval.
  61. * @param {number} y2 Middle value of the interval.
  62. * @param {number} y3 End value of the interval.
  63. * @param {number} n Location (-0.5 >= n >= 0.5) of result in the interval.
  64. * @param {boolean} normalize Whether the final result should be normalized.
  65. * @returns {number} Interpolated result.
  66. */
  67. const interpolateFromThree = (y1, y2, y3, n, normalize = false) => {
  68. let a = y2 - y1;
  69. let b = y3 - y2;
  70. if (typeof normalize !== 'undefined' && normalize) {
  71. if (a < 0) {
  72. a += 360;
  73. }
  74. if (b < 0) {
  75. b += 360;
  76. }
  77. }
  78. const c = b - a;
  79. return y2 + (n / 2) * (a + b + n * c);
  80. };
  81. /**
  82. * Converts a datetime in UTC to the corresponding Julian Date (see AA p60f).
  83. * @param {DateTime} datetime Datetime to be converted.
  84. * @returns {number} Julian date (fractional number of days since 1 January
  85. * 4713BC according to the proleptic Julian calendar.
  86. */
  87. const datetimeToJD = (datetime) => {
  88. let Y = datetime.year;
  89. let M = datetime.month;
  90. const D = datetime.day + (datetime.hour + (datetime.minute + datetime.second / 60) / 60) / 24;
  91. if (M < 3) {
  92. Y -= 1;
  93. M += 12;
  94. }
  95. const A = Math.floor(Y / 100);
  96. // Need a different B if we are before introduction of the Gregorian Calendar
  97. const gregorianCutoff = DateTime.fromISO('1582-10-15T12:00:00Z', { zone: 'UTC' });
  98. let B = 0;
  99. if (datetime > gregorianCutoff) {
  100. B = 2 - A + Math.floor(A / 4);
  101. }
  102. return Math.floor(365.25 * (Y + 4716)) + Math.floor(30.6001 * (M + 1)) + D + B - 1524.5;
  103. };
  104. /**
  105. * Converts a Julian date to the number of Julian centuries since
  106. * 2000-01-01T12:00:00Z (see AA p87 Eq12.1).
  107. * @param {number} JD Julian date.
  108. * @returns {number} T.
  109. */
  110. const JDToT = (JD) => (JD - 2451545) / 36525;
  111. /**
  112. * Converts a datetime in UTC to the number of Julian centuries since
  113. * 2000-01-01T12:00:00Z.
  114. * @param {DateTime} datetime Datetime to be converted.
  115. * @returns {number} T.
  116. */
  117. const datetimeToT = (datetime) => JDToT(datetimeToJD(datetime));
  118. /* eslint-disable complexity */
  119. /**
  120. * Calculates the value of ΔT=TT−UT (see
  121. * http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html).
  122. * @param {DateTime} datetime Datetime for which ΔT should be calculated.
  123. * @returns {number} ΔT.
  124. */
  125. const DeltaT = (datetime) => {
  126. let y = datetime.year;
  127. y += (datetime.month - 0.5) / 12;
  128. let u;
  129. let t;
  130. switch (true) {
  131. case y < -1999 || y > 3000:
  132. throw 'DeltaT can only be calculated between 1999 BCE and 3000 CE';
  133. case y < -500:
  134. u = (y - 1820) / 100;
  135. return -20 + 32 * Math.pow(u, 2);
  136. case y < 500:
  137. u = y / 100;
  138. return polynomial(u, [10583.6, -1014.41, 33.78311, -5.952053, -0.1798452, 0.022174192, 0.0090316521]);
  139. case y < 1600:
  140. u = (y - 1000) / 100;
  141. return polynomial(u, [1574.2, -556.01, 71.23472, 0.319781, -0.8503463, -0.005050998, 0.0083572073]);
  142. case y < 1700:
  143. t = y - 1600;
  144. return polynomial(t, [120, -0.9808, -0.01532, 1 / 7129]);
  145. case y < 1800:
  146. t = y - 1700;
  147. return polynomial(t, [8.83, 0.1603, -0.0059285, 0.00013336, -1 / 1174000]);
  148. case y < 1860:
  149. t = y - 1800;
  150. return polynomial(t, [13.72, -0.332447, 0.0068612, 0.0041116, -0.00037436, 0.0000121272, -0.0000001699, 0.000000000875]);
  151. case y < 1900:
  152. t = y - 1860;
  153. return polynomial(t, [7.62, 0.5737, -0.251754, 0.01680668, -0.0004473624, 1 / 233174]);
  154. case y < 1920:
  155. t = y - 1900;
  156. return polynomial(t, [-2.79, 1.494119, -0.0598939, 0.0061966, -0.000197]);
  157. case y < 1941:
  158. t = y - 1920;
  159. return polynomial(t, [21.20, 0.84493, -0.076100, 0.0020936]);
  160. case y < 1961:
  161. t = y - 1950;
  162. return polynomial(t, [29.07, 0.407, -1 / 233, 1 / 2547]);
  163. case y < 1986:
  164. t = y - 1975;
  165. return polynomial(t, [45.45, 1.067, -1 / 260, -1 / 718]);
  166. case y < 2005:
  167. t = y - 2000;
  168. return polynomial(t, [63.86, 0.3345, -0.060374, 0.0017275, 0.000651814, 0.00002373599]);
  169. case y < 2050:
  170. t = y - 2000;
  171. return polynomial(t, [62.92, 0.32217, 0.005589]);
  172. case y < 2150:
  173. return -20 + 32 * Math.pow(((y - 1820) / 100), 2) - 0.5628 * (2150 - y);
  174. default:
  175. u = (y - 1820) / 100;
  176. return -20 + 32 * Math.pow(u, 2);
  177. }
  178. };
  179. let roundToNearestMinute = false;
  180. let returnTimeForNoEventCase = false;
  181. let dateFormatKeys = {
  182. SUN_HIGH: '‡',
  183. SUN_LOW: '†',
  184. };
  185. const settings = (settings) => {
  186. if (typeof settings.roundToNearestMinute === 'boolean') {
  187. roundToNearestMinute = settings.roundToNearestMinute;
  188. }
  189. if (typeof settings.returnTimeForNoEventCase === 'boolean') {
  190. returnTimeForNoEventCase = settings.returnTimeForNoEventCase;
  191. }
  192. if (typeof settings.dateFormatKeys === 'object') {
  193. dateFormatKeys = settings.dateFormatKeys;
  194. }
  195. };
  196. /** See AA p144 */
  197. const sunMeanAnomaly = [357.52772, 35999.050340, -0.0001603, -1 / 300000];
  198. /** See AA p163 Eq 25.2 */
  199. const sunMeanLongitude = [280.46646, 36000.76983, 0.0003032];
  200. /** See AA p147 Eq22.3 */
  201. const meanObliquityOfEcliptic = [84381.448 / 3600, -4680.93 / 3600, -1.55 / 3600, 1999.25 / 3600, -51.38 / 3600, -249.67 / 3600, -39.05 / 3600,
  202. 7.12 / 3600, 27.87 / 3600, 5.79 / 3600, 2.45 / 3600];
  203. /** See AA p144 */
  204. const moonArgumentOfLatitude = [93.27191, 483202.017538, -0.0036825, 1 / 327270];
  205. /** See AA p144 */
  206. const moonAscendingNodeLongitude = [125.04452, -1934.136261, 0.0020708, 1 / 450000];
  207. /** See AA p144 */
  208. const moonMeanAnomaly = [134.96298, 477198.867398, 0.0086972, 1 / 56250];
  209. /** See AA p144 */
  210. const moonMeanElongation = [297.85036, 445267.111480, -0.0019142, 1 / 189474];
  211. /* eslint-disable no-multi-spaces, array-bracket-spacing */
  212. /**
  213. * Nutations in longitude and obliquity
  214. * See AA p145f
  215. */
  216. const nutations = [
  217. [0, 0, 0, 0, 1, -171996, -174.2, 92025, 8.9],
  218. [-2, 0, 0, 2, 2, -13187, -1.6, 5736, -3.1],
  219. [0, 0, 0, 2, 2, -2274, -0.2, 977, -0.5],
  220. [0, 0, 0, 0, 2, 2062, 0.2, -895, 0.5],
  221. [0, 1, 0, 0, 0, 1426, -3.4, 54, -0.1],
  222. [0, 0, 1, 0, 0, 712, 0.1, -7, 0],
  223. [-2, 1, 0, 2, 2, -517, 1.2, 224, -0.6],
  224. [0, 0, 0, 2, 1, -386, -0.4, 200, 0],
  225. [0, 0, 1, 2, 2, -301, 0, 129, -0.1],
  226. [-2, -1, 0, 2, 2, 217, -0.5, -95, 0.3],
  227. [-2, 0, 1, 0, 0, -158, 0, 0, 0],
  228. [-2, 0, 0, 2, 1, 129, 0.1, -70, 0],
  229. [0, 0, -1, 2, 2, 123, 0, -53, 0],
  230. [2, 0, 0, 0, 0, 63, 0, 0, 0],
  231. [0, 0, 1, 0, 1, 63, 0.1, -33, 0],
  232. [2, 0, -1, 2, 2, -59, 0, 26, 0],
  233. [0, 0, -1, 0, 1, -58, -0.1, 32, 0],
  234. [0, 0, 1, 2, 1, -51, 0, 27, 0],
  235. [-2, 0, 2, 0, 0, 48, 0, 0, 0],
  236. [0, 0, -2, 2, 1, 46, 0, -24, 0],
  237. [2, 0, 0, 2, 2, -38, 0, 16, 0],
  238. [0, 0, 2, 2, 2, -31, 0, 13, 0],
  239. [0, 0, 2, 0, 0, 29, 0, 0, 0],
  240. [-2, 0, 1, 2, 2, 29, 0, -12, 0],
  241. [0, 0, 0, 2, 0, 26, 0, 0, 0],
  242. [-2, 0, 0, 2, 0, -22, 0, 0, 0],
  243. [0, 0, -1, 2, 1, 21, 0, -10, 0],
  244. [0, 2, 0, 0, 0, 17, -0.1, 0, 0],
  245. [2, 0, -1, 0, 1, 16, 0, -8, 0],
  246. [-2, 2, 0, 2, 2, -16, 0.1, 7, 0],
  247. [0, 1, 0, 0, 1, -15, 0, 9, 0],
  248. [-2, 0, 1, 0, 1, -13, 0, 7, 0],
  249. [0, -1, 0, 0, 1, -12, 0, 6, 0],
  250. [0, 0, 2, -2, 0, 11, 0, 0, 0],
  251. [2, 0, -1, 2, 1, -10, 0, 5, 0],
  252. [2, 0, 1, 2, 2, -8, 0, 3, 0],
  253. [0, 1, 0, 2, 2, 7, 0, -3, 0],
  254. [-2, 1, 1, 0, 0, -7, 0, 0, 0],
  255. [0, -1, 0, 2, 2, -7, 0, 3, 0],
  256. [2, 0, 0, 2, 1, -7, 0, 3, 0],
  257. [2, 0, 1, 0, 0, 6, 0, 0, 0],
  258. [-2, 0, 2, 2, 2, 6, 0, -3, 0],
  259. [-2, 0, 1, 2, 1, 6, 0, -3, 0],
  260. [2, 0, -2, 0, 1, -6, 0, 3, 0],
  261. [2, 0, 0, 0, 1, -6, 0, 3, 0],
  262. [0, -1, 1, 0, 0, 5, 0, 0, 0],
  263. [-2, -1, 0, 2, 1, -5, 0, 3, 0],
  264. [-2, 0, 0, 0, 1, -5, 0, 3, 0],
  265. [0, 0, 2, 2, 1, -5, 0, 3, 0],
  266. [-2, 0, 2, 0, 1, 4, 0, 0, 0],
  267. [-2, 1, 0, 2, 1, 4, 0, 0, 0],
  268. [0, 0, 1, -2, 0, 4, 0, 0, 0],
  269. [-1, 0, 1, 0, 0, -4, 0, 0, 0],
  270. [-2, 1, 0, 0, 0, -4, 0, 0, 0],
  271. [1, 0, 0, 0, 0, -4, 0, 0, 0],
  272. [0, 0, 1, 2, 0, 3, 0, 0, 0],
  273. [0, 0, -2, 2, 2, -3, 0, 0, 0],
  274. [-1, -1, 1, 0, 0, -3, 0, 0, 0],
  275. [0, 1, 1, 0, 0, -3, 0, 0, 0],
  276. [0, -1, 1, 2, 2, -3, 0, 0, 0],
  277. [2, -1, -1, 2, 2, -3, 0, 0, 0],
  278. [0, 0, 3, 2, 2, 3, 0, 0, 0],
  279. [2, -1, 0, 2, 2, -3, 0, 0, 0],
  280. ];
  281. /**
  282. * Calculates the solar transit time on a date at a given longitude (see AA
  283. * p102f).
  284. * @param {DateTime} datetime Date for which transit is calculated.
  285. * @param {number} L Longitude.
  286. * @returns {DateTime} Solar transit time.
  287. */
  288. const sunTransit = (datetime, L) => {
  289. const timezone = datetime.zone;
  290. let transit = datetime.set({ hour: 0, minute: 0, second: 0, millisecond: 0 })
  291. .setZone('UTC', { keepLocalTime: true });
  292. const deltaT = DeltaT(transit);
  293. const T = datetimeToT(transit);
  294. const Theta0 = apparentSiderealTimeGreenwich(T);
  295. // Want 0h TD for this, not UT
  296. const TD = T - (deltaT / (3600 * 24 * 36525));
  297. const alpha = sunApparentRightAscension(TD);
  298. // Sign flip for longitude from AA as we take East as positive
  299. let m = (alpha - L - Theta0) / 360;
  300. m = normalizeM(m, datetime.offset);
  301. const DeltaM = sunTransitCorrection(T, Theta0, deltaT, L, m);
  302. m += DeltaM;
  303. transit = transit.plus({ seconds: Math.floor(m * 3600 * 24 + 0.5) });
  304. if (roundToNearestMinute) {
  305. transit = transit.plus({ seconds: 30 }).set({ second: 0 });
  306. }
  307. return transit.setZone(timezone);
  308. };
  309. /**
  310. * Calculates the sunrise or sunset time on a date at a given latitude and
  311. * longitude (see AA p102f).
  312. * @param {DateTime} datetime Date for which sunrise or sunset is calculated.
  313. * @param {number} phi Latitude.
  314. * @param {number} L Longitude.
  315. * @param {string} flag 'RISE' or 'SET' depending on which event should be
  316. * calculated.
  317. * @param {number} offset number of degrees below the horizon for the desired
  318. * event (50/60 for sunrise/set, 6 for civil, 12 for nautical, 18 for
  319. * astronomical dawn/dusk.
  320. * @returns {DateTime} Sunrise or sunset time.
  321. */
  322. // eslint-disable-next-line complexity,require-jsdoc
  323. const sunRiseSet = (datetime, phi, L, flag, offset = 50 / 60) => {
  324. const timezone = datetime.zone;
  325. let suntime = datetime.set({ hour: 0, minute: 0, second: 0, millisecond: 0 })
  326. .setZone('UTC', { keepLocalTime: true });
  327. const deltaT = DeltaT(suntime);
  328. const T = datetimeToT(suntime);
  329. const Theta0 = apparentSiderealTimeGreenwich(T);
  330. // Want 0h TD for this, not UT
  331. const TD = T - (deltaT / (3600 * 24 * 36525));
  332. const alpha = sunApparentRightAscension(TD);
  333. const delta = sunApparentDeclination(TD);
  334. const H0 = approxLocalHourAngle(phi, delta, offset);
  335. // Sign flip for longitude from AA as we take East as positive
  336. let m0 = (alpha - L - Theta0) / 360;
  337. m0 = normalizeM(m0, datetime.offset);
  338. let m;
  339. if (flag === 'RISE') {
  340. m = m0 - H0 / 360;
  341. }
  342. else {
  343. m = m0 + H0 / 360;
  344. }
  345. let counter = 0;
  346. let DeltaM = 1;
  347. // Repeat if correction is larger than ~9s
  348. while ((Math.abs(DeltaM) > 0.0001) && (counter < 3)) {
  349. DeltaM = sunRiseSetCorrection(T, Theta0, deltaT, phi, L, m, offset);
  350. m += DeltaM;
  351. counter++;
  352. }
  353. if (m > 0) {
  354. suntime = suntime.plus({ seconds: Math.floor(m * 3600 * 24 + 0.5) });
  355. }
  356. else {
  357. suntime = suntime.minus({ seconds: Math.floor(m * 3600 * 24 + 0.5) });
  358. }
  359. if (roundToNearestMinute) {
  360. suntime = suntime.plus({ seconds: 30 }).set({ second: 0 });
  361. }
  362. return suntime.setZone(timezone);
  363. };
  364. /**
  365. * Returns a fixed time as given by the hour parameter, an hour later during DST) if the
  366. * specified event does not occur on the date and returnTimeForNoEventCase is true. If
  367. * false, return whether the reason for no event is the sun being too high ('SUN_HIGH')
  368. * or too low ('SUN_LOW').
  369. * @param {DateTime} date The original date from which the event was calculated.
  370. * @param {string|undefined} errorCode The error code in case no event was found
  371. * @param {number} hour Hour to which the returned datetime should be set.
  372. * @param {number} minute Minute to which the returned datetime should be set.
  373. * @returns {(DateTime|string)} Time given by parameter 'hour' (+ correction for
  374. * DST if applicable) or a string indicating why there was no event ('SUN_HIGH'
  375. * or 'SUN_LOW')
  376. */
  377. const handleNoEventCase = (date, errorCode, hour, minute = 0) => {
  378. if (returnTimeForNoEventCase) {
  379. const returnDate = date.set({ hour, minute, second: 0 }).plus({ minutes: date.isInDST ? 60 : 0 });
  380. returnDate.errorCode = errorCode;
  381. return returnDate;
  382. }
  383. return errorCode;
  384. };
  385. /**
  386. * Calculates the approximate local hour angle of the sun at sunrise or sunset.
  387. * @param {number} phi Latitude (see AA p102 Eq15.1).
  388. * @param {number} delta Apparent declination of the sun.
  389. * @param {number} offset number of degrees below the horizon for the desired
  390. * event (50/60 for sunrise/set, 6 for civil, 12 for nautical, 18 for
  391. * astronomical dawn/dusk.
  392. * @returns {number} Approximate local hour angle.
  393. */
  394. const approxLocalHourAngle = (phi, delta, offset) => {
  395. const cosH0 = (sind(-offset) -
  396. sind(phi) * sind(delta)) /
  397. (cosd(phi) * cosd(delta));
  398. if (cosH0 < -1) {
  399. throw noEventCodes.SUN_HIGH;
  400. }
  401. else if (cosH0 > 1) {
  402. throw noEventCodes.SUN_LOW;
  403. }
  404. return rad2deg(Math.acos(cosH0));
  405. };
  406. /**
  407. * Normalizes a fractional time of day to be on the correct date.
  408. * @param {number} m Fractional time of day
  409. * @param {number} utcOffset Offset in minutes from UTC.
  410. * @returns {number} m Normalized m.
  411. */
  412. const normalizeM = (m, utcOffset) => {
  413. const localM = m + utcOffset / 1440;
  414. if (localM < 0) {
  415. return m + 1;
  416. }
  417. else if (localM > 1) {
  418. return m - 1;
  419. }
  420. return m;
  421. };
  422. /**
  423. * Calculates the correction for the solar transit time (see AA p103).
  424. * @param {number} T Fractional number of Julian centuries since
  425. * 2000-01-01T12:00:00Z.
  426. * @param {number} Theta0 Apparent sidereal time at Greenwich.
  427. * @param {number} deltaT ΔT = TT − UT.
  428. * @param {number} L Longitude.
  429. * @param {number} m Fractional time of day of the event.
  430. * @returns {number} Currection for the solar transit time.
  431. */
  432. const sunTransitCorrection = (T, Theta0, deltaT, L, m) => {
  433. const theta0 = Theta0 + 360.985647 * m;
  434. const n = m + deltaT / 864000;
  435. const alpha = interpolatedRa(T, n);
  436. const H = localHourAngle(theta0, L, alpha);
  437. return -H / 360;
  438. };
  439. /**
  440. * Calculates the correction for the sunrise/sunset time (see AA p103).
  441. * @param {number} T Fractional number of Julian centuries since
  442. * 2000-01-01T12:00:00Z.
  443. * @param {number} Theta0 Apparent sidereal time at Greenwich.
  444. * @param {number} deltaT ΔT = TT − UT.
  445. * @param {number} phi Latitude.
  446. * @param {number} L Longitude.
  447. * @param {number} m Fractional time of day of the event.
  448. * @param {number} offset number of degrees below the horizon for the desired
  449. * event (50/60 for sunrise/set, 6 for civil, 12 for nautical, 18 for
  450. * astronomical dawn/dusk.
  451. * @returns {number} Correction for the sunrise/sunset time.
  452. */
  453. const sunRiseSetCorrection = (T, Theta0, deltaT, phi, L, m, offset) => {
  454. const theta0 = Theta0 + 360.985647 * m;
  455. const n = m + deltaT / 864000;
  456. const alpha = interpolatedRa(T, n);
  457. const delta = interpolatedDec(T, n);
  458. const H = localHourAngle(theta0, L, alpha);
  459. const h = altitude(phi, delta, H);
  460. return (h + offset) / (360 * cosd(delta) * cosd(phi) * sind(H));
  461. };
  462. /**
  463. * Calculates the local hour angle of the sun (see AA p103).
  464. * @param {number} theta0 Sidereal time at Greenwich in degrees.
  465. * @param {number} L Longitude.
  466. * @param {number} alpha Apparent right ascension of the sun.
  467. * @returns {number} Local hour angle of the sun.
  468. */
  469. const localHourAngle = (theta0, L, alpha) => {
  470. // Sign flip for longitude
  471. let H = reduceAngle(theta0 + L - alpha);
  472. if (H > 180) {
  473. H -= 360;
  474. }
  475. return H;
  476. };
  477. /**
  478. * Calculates the altitude of the sun above the horizon (see AA P93 Eq13.6).
  479. * @param {number} phi Latitude.
  480. * @param {number} delta Apparent declination of the sun.
  481. * @param {number} H Local hour angle of the sun.
  482. * @returns {number} Altitude of the sun above the horizon.
  483. */
  484. const altitude = (phi, delta, H) => rad2deg(Math.asin(sind(phi) * sind(delta) + cosd(phi) * cosd(delta) * cosd(H)));
  485. /**
  486. * Interpolates the sun's right ascension (see AA p103).
  487. * @param {number} T Fractional number of Julian centuries since
  488. * 2000-01-01T12:00:00Z.
  489. * @param {number} n Fractional time of day of the event corrected by ΔT.
  490. * @returns {number} Interpolated right ascension.
  491. */
  492. const interpolatedRa = (T, n) => {
  493. const alpha1 = sunApparentRightAscension(T - (1 / 36525));
  494. const alpha2 = sunApparentRightAscension(T);
  495. const alpha3 = sunApparentRightAscension(T + (1 / 36525));
  496. const alpha = interpolateFromThree(alpha1, alpha2, alpha3, n, true);
  497. return reduceAngle(alpha);
  498. };
  499. /**
  500. * Interpolates the sun's declination (see AA p103).
  501. * @param {number} T Fractional number of Julian centuries since
  502. * 2000-01-01T12:00:00Z.
  503. * @param {number} n Fractional time of day of the event corrected by ΔT.
  504. * @returns {number} Interpolated declination.
  505. */
  506. const interpolatedDec = (T, n) => {
  507. const delta1 = sunApparentDeclination(T - (1 / 36525));
  508. const delta2 = sunApparentDeclination(T);
  509. const delta3 = sunApparentDeclination(T + (1 / 36525));
  510. const delta = interpolateFromThree(delta1, delta2, delta3, n);
  511. return reduceAngle(delta);
  512. };
  513. /**
  514. * Calculates the apparent right ascension of the sun (see AA p165 Eq25.6).
  515. * @param {number} T Fractional number of Julian centuries since
  516. * 2000-01-01T12:00:00Z.
  517. * @returns {number} Apparent right ascension of the sun.
  518. */
  519. const sunApparentRightAscension = (T) => {
  520. const Omega = moonAscendingNodeLongitude$1(T);
  521. const epsilon = trueObliquityOfEcliptic(T) + 0.00256 * cosd(Omega);
  522. const lambda = sunApparentLongitude(T);
  523. const alpha = rad2deg(Math.atan2(cosd(epsilon) * sind(lambda), cosd(lambda)));
  524. return reduceAngle(alpha);
  525. };
  526. /**
  527. * Calculates the apparent declination of the sun (see AA p165 Eq25.7).
  528. * @param {number} T Fractional number of Julian centuries since
  529. * 2000-01-01T12:00:00Z.
  530. * @returns {number} Apparent declination of the sun.
  531. */
  532. const sunApparentDeclination = (T) => {
  533. const Omega = moonAscendingNodeLongitude$1(T);
  534. const epsilon = trueObliquityOfEcliptic(T) + 0.00256 * cosd(Omega);
  535. const lambda = sunApparentLongitude(T);
  536. return rad2deg(Math.asin(sind(epsilon) * sind(lambda)));
  537. };
  538. /**
  539. * Calculates the apparent sidereal time at Greenwich (see AA p88).
  540. * @param {number} T Fractional number of Julian centuries since
  541. * 2000-01-01T12:00:00Z.
  542. * @returns {number} Apparent sidereal time at Greenwich
  543. */
  544. const apparentSiderealTimeGreenwich = (T) => {
  545. const theta0 = meanSiderealTimeGreenwich(T);
  546. const epsilon = trueObliquityOfEcliptic(T);
  547. const DeltaPsi = nutationInLongitude(T);
  548. const theta = theta0 + DeltaPsi * cosd(epsilon);
  549. return reduceAngle(theta);
  550. };
  551. /**
  552. * Calculates the mean sidereal time at Greenwich (see AA p88 Eq12.4).
  553. * @param {number} T Fractional number of Julian centuries since
  554. * 2000-01-01T12:00:00Z.
  555. * @returns {number} Mean sidereal time at Greenwich
  556. */
  557. const meanSiderealTimeGreenwich = (T) => {
  558. const JD2000 = T * 36525;
  559. return 280.46061837 + 360.98564736629 * JD2000 + 0.000387933 * Math.pow(T, 2) - Math.pow(T, 3) / 38710000;
  560. };
  561. /**
  562. * Calculates the true obliquity of the ecliptic (see AA p147).
  563. * @param {number} T Fractional number of Julian centuries since
  564. * 2000-01-01T12:00:00Z.
  565. * @returns {number} True obliquity of the ecliptic.
  566. */
  567. const trueObliquityOfEcliptic = (T) => {
  568. const epsilon0 = meanObliquityOfEcliptic$1(T);
  569. const DeltaEpsilon = nutationInObliquity(T);
  570. return epsilon0 + DeltaEpsilon;
  571. };
  572. /**
  573. * Calculates the mean obliquity of the ecliptic (see AA p147 Eq 22.3).
  574. * @param {number} T Fractional number of Julian centuries since
  575. * 2000-01-01T12:00:00Z.
  576. * @returns {number} Mean obliquity of the ecliptic.
  577. */
  578. const meanObliquityOfEcliptic$1 = (T) => {
  579. const U = T / 100;
  580. return polynomial(U, meanObliquityOfEcliptic);
  581. };
  582. /**
  583. * Calculates the apparent longitude of the sun (see AA p164).
  584. * @param {number} T Fractional number of Julian centuries since
  585. * 2000-01-01T12:00:00Z.
  586. * @returns {number} Apparent longitude of the sun.
  587. */
  588. const sunApparentLongitude = (T) => {
  589. const Sol = sunTrueLongitude(T);
  590. const Omega = moonAscendingNodeLongitude$1(T);
  591. return Sol - 0.00569 - 0.00478 * sind(Omega);
  592. };
  593. /**
  594. * Calculates the true longitude of the sun (see AA p164).
  595. * @param {number} T Fractional number of Julian centuries since
  596. * 2000-01-01T12:00:00Z.
  597. * @returns {number} True longitude of the sun.
  598. */
  599. const sunTrueLongitude = (T) => {
  600. const L0 = sunMeanLongitude$1(T);
  601. const C = sunEquationOfCenter(T);
  602. return L0 + C;
  603. };
  604. /**
  605. * Calculates the equation of center of the sun (see AA p164).
  606. * @param {number} T Fractional number of Julian centuries since
  607. * 2000-01-01T12:00:00Z.
  608. * @returns {number} Equation of center of the sun.
  609. */
  610. const sunEquationOfCenter = (T) => {
  611. const M = sunMeanAnomaly$1(T);
  612. return (1.914602 - 0.004817 * T - 0.000014 * Math.pow(T, 2)) * sind(M) +
  613. (0.019993 - 0.000101 * T) * sind(2 * M) + 0.000290 * sind(3 * M);
  614. };
  615. /**
  616. * Calculates the nutation in longitude of the sun (see AA p144ff).
  617. * @param {number} T Fractional number of Julian centuries since
  618. * 2000-01-01T12:00:00Z.
  619. * @returns {number} Nutation in longitude of the sun.
  620. */
  621. const nutationInLongitude = (T) => {
  622. const D = moonMeanElongation$1(T);
  623. const M = sunMeanAnomaly$1(T);
  624. const MPrime = moonMeanAnomaly$1(T);
  625. const F = moonArgumentOfLatitude$1(T);
  626. const Omega = moonAscendingNodeLongitude$1(T);
  627. let DeltaPsi = 0;
  628. let sineArg;
  629. for (let i = 0; i < 63; i++) {
  630. sineArg = nutations[i][0] * D + nutations[i][1] * M + nutations[i][2] * MPrime +
  631. nutations[i][3] * F + nutations[i][4] * Omega;
  632. DeltaPsi += (nutations[i][5] + nutations[i][6] * T) * sind(sineArg);
  633. }
  634. return DeltaPsi / 36000000;
  635. };
  636. /**
  637. * Calculates the nutation in obliquity of the sun (see AA p144ff).
  638. * @param {number} T Fractional number of Julian centuries since
  639. * 2000-01-01T12:00:00Z.
  640. * @returns {number} Nutation in obliquity of the sun.
  641. */
  642. const nutationInObliquity = (T) => {
  643. const D = moonMeanElongation$1(T);
  644. const M = sunMeanAnomaly$1(T);
  645. const MPrime = moonMeanAnomaly$1(T);
  646. const F = moonArgumentOfLatitude$1(T);
  647. const Omega = moonAscendingNodeLongitude$1(T);
  648. let DeltaEpsilon = 0;
  649. let cosArg;
  650. for (let i = 0; i < 63; i++) {
  651. cosArg = nutations[i][0] * D + nutations[i][1] * M + nutations[i][2] * MPrime +
  652. nutations[i][3] * F + nutations[i][4] * Omega;
  653. DeltaEpsilon += (nutations[i][7] + nutations[i][8] * T) * cosd(cosArg);
  654. }
  655. return DeltaEpsilon / 36000000;
  656. };
  657. /**
  658. * Calculates the argument of latitude of the moon (see AA p144).
  659. * @param {number} T Fractional number of Julian centuries since
  660. * 2000-01-01T12:00:00Z.
  661. * @returns {number} Argument of latitude of the moon.
  662. */
  663. const moonArgumentOfLatitude$1 = (T) => {
  664. const F = polynomial(T, moonArgumentOfLatitude);
  665. return reduceAngle(F);
  666. };
  667. /**
  668. * Calculates the longitude of the ascending node of the Moon's mean orbit on
  669. * the ecliptic, measured from the mean equinox of the datea (see AA p144).
  670. * @param {number} T Fractional number of Julian centuries since
  671. * 2000-01-01T12:00:00Z.
  672. * @returns {number} Longitude of the asc. node of the moon's mean orbit.
  673. */
  674. const moonAscendingNodeLongitude$1 = (T) => {
  675. const Omega = polynomial(T, moonAscendingNodeLongitude);
  676. return reduceAngle(Omega);
  677. };
  678. /**
  679. * Calculates the mean anomaly of the moon (see AA p144).
  680. * @param {number} T Fractional number of Julian centuries since
  681. * 2000-01-01T12:00:00Z.
  682. * @returns {number} Mean anomaly of the moon.
  683. */
  684. const moonMeanAnomaly$1 = (T) => {
  685. const MPrime = polynomial(T, moonMeanAnomaly);
  686. return reduceAngle(MPrime);
  687. };
  688. /**
  689. * Calculates the mean elongation of the moon from the sun (see AA p144).
  690. * @param {number} T Fractional number of Julian centuries since
  691. * 2000-01-01T12:00:00Z.
  692. * @returns {number} Mean elongation of the moon from the sun.
  693. */
  694. const moonMeanElongation$1 = (T) => {
  695. const D = polynomial(T, moonMeanElongation);
  696. return reduceAngle(D);
  697. };
  698. /**
  699. * Calculates the mean anomaly of the sun (see AA p144).
  700. * @param {number} T Fractional number of Julian centuries since
  701. * 2000-01-01T12:00:00Z.
  702. * @returns {number} Mean anomaly of the sun.
  703. */
  704. const sunMeanAnomaly$1 = (T) => {
  705. const M = polynomial(T, sunMeanAnomaly);
  706. return reduceAngle(M);
  707. };
  708. /**
  709. * Calculates the mean longitude of the sun referred to the mean equinox of the
  710. * date (see AA p163).
  711. * @param {number} T Fractional number of Julian centuries since
  712. * 2000-01-01T12:00:00Z.
  713. * @returns {number} Mean longitude of the sun referred to the mean equinox of
  714. * the date.
  715. */
  716. const sunMeanLongitude$1 = (T) => {
  717. const L0 = polynomial(T, sunMeanLongitude);
  718. return reduceAngle(L0);
  719. };
  720. const noEventCodes = {
  721. SUN_HIGH: 'SUN_HIGH',
  722. SUN_LOW: 'SUN_LOW',
  723. };
  724. /**
  725. * Calculates sunrise on the provided date.
  726. * @param {DateTime} datetime Datetime for which sunrise is calculated. Should
  727. * always contain a timezone or be in UTC, lone UTC offsets might lead to
  728. * unexpected behaviour.
  729. * @param {number} latitude Latitude of target location.
  730. * @param {number} longitude longitude of target location.
  731. * @returns {(DateTime|string)} Time of sunrise or a string indicating that no
  732. * event could be calculated as the sun was too high ('SUN_HIGH') or too low
  733. * ('SUN_LOW') during the entire day (unless returnTimeForNoEventCase is true).
  734. */
  735. const sunrise = (datetime, latitude, longitude) => {
  736. try {
  737. return sunRiseSet(datetime, latitude, longitude, 'RISE');
  738. }
  739. catch (err) {
  740. return handleNoEventCase(datetime, err, 6);
  741. }
  742. };
  743. /**
  744. * Calculates sunset on the provided date.
  745. * @param {DateTime} datetime Datetime for which sunset is calculated. Should
  746. * always contain a timezone or be in UTC, lone UTC offsets might lead to
  747. * unexpected behaviour.
  748. * @param {number} latitude Latitude of target location.
  749. * @param {number} longitude longitude of target location.
  750. * @returns {(DateTime|string)} Time of sunset or a string indicating that no
  751. * event could be calculated as the sun was too high ('SUN_HIGH') or too low
  752. * ('SUN_LOW') during the entire day (unless returnTimeForNoEventCase is true).
  753. */
  754. const sunset = (datetime, latitude, longitude) => {
  755. try {
  756. return sunRiseSet(datetime, latitude, longitude, 'SET');
  757. }
  758. catch (err) {
  759. return handleNoEventCase(datetime, err, 18);
  760. }
  761. };
  762. /**
  763. * Calculates solar noon on the provided date.
  764. * @param {DateTime} datetime Datetime for which solar noon is calculated. Should
  765. * always contain a timezone or be in UTC, lone UTC offsets might lead to
  766. * unexpected behaviour.
  767. * @param {number} longitude longitude of target location.
  768. * @returns {DateTime} Time of solar noon at the given longitude.
  769. */
  770. const solarNoon = (datetime, longitude) => sunTransit(datetime, longitude);
  771. const month = {
  772. 1: 'Bahá',
  773. 2: 'Jalál',
  774. 3: 'Jamál',
  775. 4: '‘Aẓamat',
  776. 5: 'Núr',
  777. 6: 'Raḥmat',
  778. 7: 'Kalimát',
  779. 8: 'Kamál',
  780. 9: 'Asmá’',
  781. 10: '‘Izzat',
  782. 11: 'Ma_sh_íyyat',
  783. 12: '‘Ilm',
  784. 13: 'Qudrat',
  785. 14: 'Qawl',
  786. 15: 'Masá’il',
  787. 16: '_Sh_araf',
  788. 17: 'Sulṭán',
  789. 18: 'Mulk',
  790. 19: '‘Alá’',
  791. 20: 'Ayyám-i-Há',
  792. };
  793. const monthL = {
  794. 1: 'Splendour',
  795. 2: 'Glory',
  796. 3: 'Beauty',
  797. 4: 'Grandeur',
  798. 5: 'Light',
  799. 6: 'Mercy',
  800. 7: 'Words',
  801. 8: 'Perfection',
  802. 9: 'Names',
  803. 10: 'Might',
  804. 11: 'Will',
  805. 12: 'Knowledge',
  806. 13: 'Power',
  807. 14: 'Speech',
  808. 15: 'Questions',
  809. 16: 'Honour',
  810. 17: 'Sovereignty',
  811. 18: 'Dominion',
  812. 19: 'Loftiness',
  813. 20: 'Ayyám-i-Há',
  814. };
  815. const holyDay = {
  816. 1: 'Naw-Rúz',
  817. 2: 'First day of Riḍván',
  818. 3: 'Ninth day of Riḍván',
  819. 4: 'Twelfth day of Riḍván',
  820. 5: 'Declaration of the Báb',
  821. 6: 'Ascension of Bahá’u’lláh',
  822. 7: 'Martyrdom of the Báb',
  823. 8: 'Birth of the Báb',
  824. 9: 'Birth of Bahá’u’lláh',
  825. 10: 'Day of the Covenant',
  826. 11: 'Ascension of ‘Abdu’l-Bahá',
  827. };
  828. // CAREFUL: Numbering corresponds to Badí' week, i.e. 1 is Jalál (-> Saturday)
  829. const weekday = {
  830. 1: 'Jalál',
  831. 2: 'Jamál',
  832. 3: 'Kamál',
  833. 4: 'Fiḍál',
  834. 5: '‘Idál',
  835. 6: 'Istijlál',
  836. 7: 'Istiqlál',
  837. };
  838. const weekdayAbbr3 = {
  839. 1: 'Jal',
  840. 2: 'Jam',
  841. 3: 'Kam',
  842. 4: 'Fiḍ',
  843. 5: '‘Idá',
  844. 6: 'Isj',
  845. 7: 'Isq',
  846. };
  847. const weekdayAbbr2 = {
  848. 1: 'Jl',
  849. 2: 'Jm',
  850. 3: 'Ka',
  851. 4: 'Fi',
  852. 5: '‘Id',
  853. 6: 'Ij',
  854. 7: 'Iq',
  855. };
  856. const weekdayL = {
  857. 1: 'Glory',
  858. 2: 'Beauty',
  859. 3: 'Perfection',
  860. 4: 'Grace',
  861. 5: 'Justice',
  862. 6: 'Majesty',
  863. 7: 'Independence',
  864. };
  865. const yearInVahid = {
  866. 1: 'Alif',
  867. 2: 'Bá’',
  868. 3: 'Ab',
  869. 4: 'Dál',
  870. 5: 'Báb',
  871. 6: 'Váv',
  872. 7: 'Abad',
  873. 8: 'Jád',
  874. 9: 'Bahá',
  875. 10: 'Ḥubb',
  876. 11: 'Bahháj',
  877. 12: 'Javáb',
  878. 13: 'Aḥad',
  879. 14: 'Vahháb',
  880. 15: 'Vidád',
  881. 16: 'Badí‘',
  882. 17: 'Bahí',
  883. 18: 'Abhá',
  884. 19: 'Váḥid',
  885. };
  886. const vahid = 'Váḥid';
  887. const kulliShay = 'Kull-i-_Sh_ay’';
  888. const BE = 'B.E.';
  889. const badiCalendar = 'Badí‘ Calendar';
  890. const unicodeCharForZero = '0';
  891. const defaultFormat = 'd MM+ y BE';
  892. var en = /*#__PURE__*/Object.freeze({
  893. __proto__: null,
  894. month: month,
  895. monthL: monthL,
  896. holyDay: holyDay,
  897. weekday: weekday,
  898. weekdayAbbr3: weekdayAbbr3,
  899. weekdayAbbr2: weekdayAbbr2,
  900. weekdayL: weekdayL,
  901. yearInVahid: yearInVahid,
  902. vahid: vahid,
  903. kulliShay: kulliShay,
  904. BE: BE,
  905. badiCalendar: badiCalendar,
  906. unicodeCharForZero: unicodeCharForZero,
  907. defaultFormat: defaultFormat
  908. });
  909. const month$1 = {
  910. 1: 'البهاء',
  911. 2: 'الجلال',
  912. 3: 'الجمال',
  913. 4: 'العظمة',
  914. 5: 'النور',
  915. 6: 'الرحمة',
  916. 7: 'الكلمات',
  917. 8: 'الكمال',
  918. 9: 'الأسماء',
  919. 10: 'العزّة',
  920. 11: 'المشية',
  921. 12: 'العلم',
  922. 13: 'القدرة',
  923. 14: 'القول',
  924. 15: 'المسائل',
  925. 16: 'الشرف',
  926. 17: 'السلطان',
  927. 18: 'الملك',
  928. 19: 'العلاء',
  929. 20: 'ايام الهاء',
  930. };
  931. const monthL$1 = month$1;
  932. const holyDay$1 = {
  933. 1: 'عيد النَّيروز',
  934. 2: 'اليوم الأول من عيد الرِّضوان',
  935. 3: 'اليوم التاسع من عيد الرِّضوان',
  936. 4: 'اليوم الثاني عشر من عيد الرِّضوان',
  937. 5: 'يوم إعلان دعوة حضرة الباب',
  938. 6: 'يوم صعود حضرة بهاء الله',
  939. 7: 'يوم استشهاد حضرة الباب',
  940. 8: 'يوم ولادة حضرة الباب',
  941. 9: 'يوم ولادة حضرة بهاء الله',
  942. 10: 'يوم الميثاق',
  943. 11: 'يوم صعود حضرة عبد البهاء',
  944. };
  945. const weekday$1 = {
  946. 1: 'الجلال',
  947. 2: 'الجمال',
  948. 3: 'الكمال',
  949. 4: 'الفضّال',
  950. 5: 'العدّال',
  951. 6: 'الأستجلال',
  952. 7: 'الاستقلال',
  953. };
  954. const weekdayAbbr3$1 = {
  955. 1: 'جلا',
  956. 2: 'جما',
  957. 3: 'كما',
  958. 4: 'فضّا',
  959. 5: 'عدّا',
  960. 6: 'اسج',
  961. 7: 'اسق',
  962. };
  963. const weekdayAbbr2$1 = {
  964. 1: 'جل',
  965. 2: 'جم',
  966. 3: 'كم',
  967. 4: 'فض',
  968. 5: 'عد',
  969. 6: 'اج',
  970. 7: 'اق',
  971. };
  972. const weekdayL$1 = {
  973. 1: 'الجلال',
  974. 2: 'الجمال',
  975. 3: 'الكمال',
  976. 4: 'الفضّال',
  977. 5: 'العدّال',
  978. 6: 'الأستجلال',
  979. 7: 'أستقلال',
  980. };
  981. const yearInVahid$1 = {
  982. 1: 'ألف',
  983. 2: 'باء',
  984. 3: 'أب',
  985. 4: 'دﺍﻝ',
  986. 5: 'باب',
  987. 6: 'وﺍو',
  988. 7: 'أبد',
  989. 8: 'جاد',
  990. 9: 'بهاء',
  991. 10: 'حب',
  992. 11: 'بهاج',
  993. 12: 'جواب',
  994. 13: 'احد',
  995. 14: 'وﻫﺎب',
  996. 15: 'وداد',
  997. 16: 'بدیع',
  998. 17: 'بهي',
  999. 18: 'ابهى',
  1000. 19: 'واحد',
  1001. };
  1002. const vahid$1 = 'واحد';
  1003. const kulliShay$1 = 'كل شيء';
  1004. const BE$1 = 'بديع';
  1005. const badiCalendar$1 = 'تقويم بديع';
  1006. const unicodeCharForZero$1 = '٠';
  1007. const defaultFormat$1 = '&#8207;d MM y BE&#8207;';
  1008. var ar = /*#__PURE__*/Object.freeze({
  1009. __proto__: null,
  1010. month: month$1,
  1011. monthL: monthL$1,
  1012. holyDay: holyDay$1,
  1013. weekday: weekday$1,
  1014. weekdayAbbr3: weekdayAbbr3$1,
  1015. weekdayAbbr2: weekdayAbbr2$1,
  1016. weekdayL: weekdayL$1,
  1017. yearInVahid: yearInVahid$1,
  1018. vahid: vahid$1,
  1019. kulliShay: kulliShay$1,
  1020. BE: BE$1,
  1021. badiCalendar: badiCalendar$1,
  1022. unicodeCharForZero: unicodeCharForZero$1,
  1023. defaultFormat: defaultFormat$1
  1024. });
  1025. const monthL$2 = {
  1026. 1: 'Herrlichkeit',
  1027. 2: 'Ruhm',
  1028. 3: 'Schönheit',
  1029. 4: 'Größe',
  1030. 5: 'Licht',
  1031. 6: 'Barmherzigkeit',
  1032. 7: 'Worte',
  1033. 8: 'Vollkommenheit',
  1034. 9: 'Namen',
  1035. 10: 'Macht',
  1036. 11: 'Wille',
  1037. 12: 'Wissen',
  1038. 13: 'Kraft',
  1039. 14: 'Sprache',
  1040. 15: 'Fragen',
  1041. 16: 'Ehre',
  1042. 17: 'Souveränität',
  1043. 18: 'Herrschaft',
  1044. 19: 'Erhabenheit',
  1045. 20: 'Ayyám-i-Há',
  1046. };
  1047. const holyDay$2 = {
  1048. 1: 'Naw-Rúz',
  1049. 2: 'Erster Riḍván-Tag',
  1050. 3: 'Neunter Riḍván-Tag',
  1051. 4: 'Zwölfter Riḍván-Tag',
  1052. 5: 'Erklärung des Báb',
  1053. 6: 'Hinscheiden Bahá’u’lláhs',
  1054. 7: 'Märtyrertod des Báb',
  1055. 8: 'Geburt des Báb',
  1056. 9: 'Geburt Bahá’u’lláhs',
  1057. 10: 'Tag des Bundes',
  1058. 11: 'Hinscheiden ‘Abdu’l-Bahás',
  1059. };
  1060. const weekdayL$2 = {
  1061. 1: 'Ruhm',
  1062. 2: 'Schönheit',
  1063. 3: 'Vollkommenheit',
  1064. 4: 'Gnade',
  1065. 5: 'Gerechtigkeit',
  1066. 6: 'Majestät',
  1067. 7: 'Unabhängigkeit',
  1068. };
  1069. const BE$2 = 'B.E.';
  1070. const badiCalendar$2 = 'Badí‘ Kalender';
  1071. var de = /*#__PURE__*/Object.freeze({
  1072. __proto__: null,
  1073. monthL: monthL$2,
  1074. holyDay: holyDay$2,
  1075. weekdayL: weekdayL$2,
  1076. BE: BE$2,
  1077. badiCalendar: badiCalendar$2
  1078. });
  1079. const monthL$3 = {
  1080. 1: 'Esplendor',
  1081. 2: 'Gloria',
  1082. 3: 'Belleza',
  1083. 4: 'Grandeza',
  1084. 5: 'Luz',
  1085. 6: 'Misericordia',
  1086. 7: 'Palabras',
  1087. 8: 'Perfección',
  1088. 9: 'Nombres',
  1089. 10: 'Fuerza',
  1090. 11: 'Voluntad',
  1091. 12: 'Conocimiento',
  1092. 13: 'Poder',
  1093. 14: 'Discurso',
  1094. 15: 'Preguntas',
  1095. 16: 'Honor',
  1096. 17: 'Soberanía',
  1097. 18: 'Dominio',
  1098. 19: 'Sublimidad',
  1099. 20: 'Ayyám-i-Há',
  1100. };
  1101. const holyDay$3 = {
  1102. 1: 'Naw-Rúz',
  1103. 2: 'Primer día de Riḍván',
  1104. 3: 'Noveno día de Riḍván',
  1105. 4: 'Duodécimo día de Riḍván',
  1106. 5: 'Declaración del Báb',
  1107. 6: 'Ascensión de Bahá’u’lláh',
  1108. 7: 'Martirio del Báb',
  1109. 8: 'Nacimiento del Báb',
  1110. 9: 'Nacimiento de Bahá’u’lláh',
  1111. 10: 'Día de la Alianza',
  1112. 11: 'Fallecimiento de ‘Abdu’l-Bahá',
  1113. };
  1114. const weekdayL$3 = {
  1115. 1: 'Gloria',
  1116. 2: 'Belleza',
  1117. 3: 'Perfección',
  1118. 4: 'Gracia',
  1119. 5: 'Justicia',
  1120. 6: 'Majestuosidad',
  1121. 7: 'Independencia',
  1122. };
  1123. const BE$3 = 'E.B.';
  1124. const badiCalendar$3 = 'Calendario Badí‘';
  1125. var es = /*#__PURE__*/Object.freeze({
  1126. __proto__: null,
  1127. monthL: monthL$3,
  1128. holyDay: holyDay$3,
  1129. weekdayL: weekdayL$3,
  1130. BE: BE$3,
  1131. badiCalendar: badiCalendar$3
  1132. });
  1133. const month$2 = {
  1134. 1: 'البهاء',
  1135. 2: 'الجلال',
  1136. 3: 'الجمال',
  1137. 4: 'العظمة',
  1138. 5: 'النور',
  1139. 6: 'الرحمة',
  1140. 7: 'الكلمات',
  1141. 8: 'الكمال',
  1142. 9: 'الأسماء',
  1143. 10: 'العزّة',
  1144. 11: 'المشية',
  1145. 12: 'العلم',
  1146. 13: 'القدرة',
  1147. 14: 'القول',
  1148. 15: 'المسائل',
  1149. 16: 'الشرف',
  1150. 17: 'السلطان',
  1151. 18: 'الملك',
  1152. 19: 'العلاء',
  1153. 20: 'ايام الهاء',
  1154. };
  1155. const monthL$4 = {
  1156. 1: 'بهاء',
  1157. 2: 'جلال',
  1158. 3: 'جمال',
  1159. 4: 'عظمت',
  1160. 5: 'نور',
  1161. 6: 'رحمت',
  1162. 7: 'كلمات',
  1163. 8: 'كمال',
  1164. 9: 'أسماء',
  1165. 10: 'عزّت',
  1166. 11: 'مشيت',
  1167. 12: 'علم',
  1168. 13: 'قدرت',
  1169. 14: 'قول',
  1170. 15: 'مسائل',
  1171. 16: 'شرف',
  1172. 17: 'سلطان',
  1173. 18: 'ملك',
  1174. 19: 'علاء',
  1175. 20: 'ايام ها',
  1176. };
  1177. const holyDay$4 = {
  1178. 1: 'عید نوروز',
  1179. 2: 'روز اوّل عید رضوان',
  1180. 3: 'روز نهم عید رضوان',
  1181. 4: 'روز دوازدهم عید رضوان',
  1182. 5: 'بعثت حضرت باب',
  1183. 6: 'صعود حضرت بهاالله',
  1184. 7: 'شهادت حضرت اعلی',
  1185. 8: 'تولّد حضرت اعلی',
  1186. 9: 'تولّد حضرت بهالله',
  1187. 10: 'روز عهد و میثاق',
  1188. 11: 'صعود حضرت عبدالبها',
  1189. };
  1190. const weekday$2 = {
  1191. 1: 'یوم الجلال',
  1192. 2: 'یوم الجمال',
  1193. 3: 'یوم الكمال',
  1194. 4: 'یوم الفضّال',
  1195. 5: 'یوم العدّال',
  1196. 6: 'یوم الأستجلال',
  1197. 7: 'یوم الاستقلال',
  1198. };
  1199. const weekdayAbbr3$2 = {
  1200. 1: 'جلا',
  1201. 2: 'جما',
  1202. 3: 'كما',
  1203. 4: 'فضّا',
  1204. 5: 'عدّا',
  1205. 6: 'اسج',
  1206. 7: 'اسق',
  1207. };
  1208. const weekdayAbbr2$2 = {
  1209. 1: 'جل',
  1210. 2: 'جم',
  1211. 3: 'كم',
  1212. 4: 'فض',
  1213. 5: 'عد',
  1214. 6: 'اج',
  1215. 7: 'اق',
  1216. };
  1217. const weekdayL$4 = {
  1218. 1: 'جلال',
  1219. 2: 'جمال',
  1220. 3: 'كمال',
  1221. 4: 'فضّال',
  1222. 5: 'عدّال',
  1223. 6: 'استجلال',
  1224. 7: 'استقلال',
  1225. };
  1226. const yearInVahid$2 = {
  1227. 1: 'ألف',
  1228. 2: 'باء',
  1229. 3: 'أب',
  1230. 4: 'دﺍﻝ',
  1231. 5: 'باب',
  1232. 6: 'وﺍو',
  1233. 7: 'أبد',
  1234. 8: 'جاد',
  1235. 9: 'بهاء',
  1236. 10: 'حب',
  1237. 11: 'بهاج',
  1238. 12: 'جواب',
  1239. 13: 'احد',
  1240. 14: 'وﻫﺎب',
  1241. 15: 'وداد',
  1242. 16: 'بدیع',
  1243. 17: 'بهي',
  1244. 18: 'ابهى',
  1245. 19: 'واحد',
  1246. };
  1247. const vahid$2 = 'واحد';
  1248. const kulliShay$2 = 'كل شيء';
  1249. const BE$4 = 'بديع';
  1250. const badiCalendar$4 = 'تقويم بديع';
  1251. const unicodeCharForZero$2 = '۰';
  1252. const defaultFormat$2 = '&#8207;d MML y BE&#8207;';
  1253. var fa = /*#__PURE__*/Object.freeze({
  1254. __proto__: null,
  1255. month: month$2,
  1256. monthL: monthL$4,
  1257. holyDay: holyDay$4,
  1258. weekday: weekday$2,
  1259. weekdayAbbr3: weekdayAbbr3$2,
  1260. weekdayAbbr2: weekdayAbbr2$2,
  1261. weekdayL: weekdayL$4,
  1262. yearInVahid: yearInVahid$2,
  1263. vahid: vahid$2,
  1264. kulliShay: kulliShay$2,
  1265. BE: BE$4,
  1266. badiCalendar: badiCalendar$4,
  1267. unicodeCharForZero: unicodeCharForZero$2,
  1268. defaultFormat: defaultFormat$2
  1269. });
  1270. const monthL$5 = {
  1271. 1: 'Splendeur',
  1272. 2: 'Gloire',
  1273. 3: 'Beauté',
  1274. 4: 'Grandeur',
  1275. 5: 'Lumière',
  1276. 6: 'Miséricorde',
  1277. 7: 'Paroles',
  1278. 8: 'Perfection',
  1279. 9: 'Noms',
  1280. 10: 'Puissance',
  1281. 11: 'Volonté',
  1282. 12: 'Connaissance',
  1283. 13: 'Pouvoir',
  1284. 14: 'Discours',
  1285. 15: 'Questions',
  1286. 16: 'Honneur',
  1287. 17: 'Souveraineté',
  1288. 18: 'Empire',
  1289. 19: 'Élévation',
  1290. 20: 'Ayyám-i-Há',
  1291. };
  1292. const holyDay$5 = {
  1293. 1: 'Naw-Rúz',
  1294. 2: 'Premier jour de Riḍván',
  1295. 3: 'Neuvième jour de Riḍván',
  1296. 4: 'Douzième jour de Riḍván',
  1297. 5: 'Déclaration du Báb',
  1298. 6: 'Ascension de Bahá’u’lláh',
  1299. 7: 'Martyre du Báb',
  1300. 8: 'Naissance du Báb',
  1301. 9: 'Naissance de Bahá’u’lláh',
  1302. 10: 'Jour de l’Alliance',
  1303. 11: 'Ascension de ‘Abdu’l-Bahá',
  1304. };
  1305. const weekdayL$5 = {
  1306. 1: 'Gloire',
  1307. 2: 'Beauté',
  1308. 3: 'Perfection',
  1309. 4: 'Grâce',
  1310. 5: 'Justice',
  1311. 6: 'Majesté',
  1312. 7: 'Indépendance',
  1313. };
  1314. const BE$5 = 'E.B.';
  1315. const badiCalendar$5 = 'Calendrier Badí‘';
  1316. var fr = /*#__PURE__*/Object.freeze({
  1317. __proto__: null,
  1318. monthL: monthL$5,
  1319. holyDay: holyDay$5,
  1320. weekdayL: weekdayL$5,
  1321. BE: BE$5,
  1322. badiCalendar: badiCalendar$5
  1323. });
  1324. const monthL$6 = {
  1325. 1: 'Spožums',
  1326. 2: 'Slava',
  1327. 3: 'Skaistums',
  1328. 4: 'Dižums',
  1329. 5: 'Gaisma',
  1330. 6: 'Žēlastība',
  1331. 7: 'Vārdi',
  1332. 8: 'Pilnība',
  1333. 9: 'Nosaukumi',
  1334. 10: 'Varenība',
  1335. 11: 'Griba',
  1336. 12: 'Zināšanas',
  1337. 13: 'Vara',
  1338. 14: 'Runa',
  1339. 15: 'Jautājumi',
  1340. 16: 'Gods',
  1341. 17: 'Suverenitāte',
  1342. 18: 'Valdīšana',
  1343. 19: 'Cēlums',
  1344. 20: 'Ayyám-i-Há',
  1345. };
  1346. const holyDay$6 = {
  1347. 1: 'Naw-Rúz',
  1348. 2: 'Riḍván pirmā diena',
  1349. 3: 'Riḍván devītā diena',
  1350. 4: 'Riḍván divpadsmitā diena',
  1351. 5: 'Bába paziņojums',
  1352. 6: 'Bahá’u’lláh Debessbraukšana',
  1353. 7: 'Bába mocekļa nāve',
  1354. 8: 'Bába dzimšanas diena',
  1355. 9: 'Bahá’u’lláh dzimšanas diena',
  1356. 10: 'Derības diena',
  1357. 11: '‘Abdu’l-Bahá Debessbraukšana',
  1358. };
  1359. const weekdayL$6 = {
  1360. 1: 'Slava',
  1361. 2: 'Skaistums',
  1362. 3: 'Pilnība',
  1363. 4: 'Žēlastība',
  1364. 5: 'Taisnīgums',
  1365. 6: 'Majestātiskums',
  1366. 7: 'Neatkarība',
  1367. };
  1368. const BE$6 = 'B.Ē.';
  1369. const badiCalendar$6 = 'Badí‘ kalendārs';
  1370. var lv = /*#__PURE__*/Object.freeze({
  1371. __proto__: null,
  1372. monthL: monthL$6,
  1373. holyDay: holyDay$6,
  1374. weekdayL: weekdayL$6,
  1375. BE: BE$6,
  1376. badiCalendar: badiCalendar$6
  1377. });
  1378. const monthL$7 = {
  1379. 1: 'Pracht',
  1380. 2: 'Heerlijkheid',
  1381. 3: 'Schoonheid',
  1382. 4: 'Grootheid',
  1383. 5: 'Licht',
  1384. 6: 'Barmhartigheid',
  1385. 7: 'Woorden',
  1386. 8: 'Volmaaktheid',
  1387. 9: 'Namen',
  1388. 10: 'Macht',
  1389. 11: 'Wil',
  1390. 12: 'Kennis',
  1391. 13: 'Kracht',
  1392. 14: 'Spraak',
  1393. 15: 'Vragen',
  1394. 16: 'Eer',
  1395. 17: 'Soevereiniteit',
  1396. 18: 'Heerschappij',
  1397. 19: 'Verhevenheid',
  1398. 20: 'Ayyám-i-Há',
  1399. };
  1400. const holyDay$7 = {
  1401. 1: 'Naw-Rúz',
  1402. 2: 'Eerste dag van Riḍván',
  1403. 3: 'Negende dag van Riḍván',
  1404. 4: 'Twaalfde dag van Riḍván',
  1405. 5: 'Verkondiging van de Báb',
  1406. 6: 'Heengaan van Bahá’u’lláh',
  1407. 7: 'Marteldood van de Báb',
  1408. 8: 'Geboortedag van de Báb',
  1409. 9: 'Geboortedag van Bahá’u’lláh',
  1410. 10: 'Dag van het Verbond',
  1411. 11: 'Heengaan van ‘Abdu’l-Bahá',
  1412. };
  1413. const weekdayL$7 = {
  1414. 1: 'Heerlijkheid',
  1415. 2: 'Schoonheid',
  1416. 3: 'Volmaaktheid',
  1417. 4: 'Genade',
  1418. 5: 'Gerechtigheid',
  1419. 6: 'Majesteit',
  1420. 7: 'Onafhankelijkheid',
  1421. };
  1422. const BE$7 = 'B.E.';
  1423. const badiCalendar$7 = 'Badí‘-Kalender';
  1424. var nl = /*#__PURE__*/Object.freeze({
  1425. __proto__: null,
  1426. monthL: monthL$7,
  1427. holyDay: holyDay$7,
  1428. weekdayL: weekdayL$7,
  1429. BE: BE$7,
  1430. badiCalendar: badiCalendar$7
  1431. });
  1432. const monthL$8 = {
  1433. 1: 'Esplendor',
  1434. 2: 'Glória',
  1435. 3: 'Beleza',
  1436. 4: 'Grandeza',
  1437. 5: 'Luz',
  1438. 6: 'Miséricórdia',
  1439. 7: 'Palavras',
  1440. 8: 'Perfeição',
  1441. 9: 'Nomes',
  1442. 10: 'Potência',
  1443. 11: 'Vontade',
  1444. 12: 'Conhecimento',
  1445. 13: 'Poder',
  1446. 14: 'Discurso',
  1447. 15: 'Perguntas',
  1448. 16: 'Honra',
  1449. 17: 'Soberania',
  1450. 18: 'Domínio',
  1451. 19: 'Sublimidade',
  1452. 20: 'Ayyám-i-Há',
  1453. };
  1454. const holyDay$8 = {
  1455. 1: 'Naw-Rúz',
  1456. 2: '1º dia do Riḍván',
  1457. 3: '9º dia do Riḍván',
  1458. 4: '12º dia do Riḍván',
  1459. 5: 'Declaração do Báb',
  1460. 6: 'Ascensão de Bahá’u’lláh',
  1461. 7: 'Martírio do Báb',
  1462. 8: 'Aniversário do Báb',
  1463. 9: 'Aniversário de Bahá’u’lláh',
  1464. 10: 'Dia do Convênio',
  1465. 11: 'Ascensão de ‘Abdu’l-Bahá',
  1466. };
  1467. const weekdayL$8 = {
  1468. 1: 'Glória',
  1469. 2: 'Beleza',
  1470. 3: 'Perfeição',
  1471. 4: 'Graça',
  1472. 5: 'Justiça',
  1473. 6: 'Majestade',
  1474. 7: 'Independência',
  1475. };
  1476. const BE$8 = 'E.B.';
  1477. const badiCalendar$8 = 'Calendário Badí‘';
  1478. var pt = /*#__PURE__*/Object.freeze({
  1479. __proto__: null,
  1480. monthL: monthL$8,
  1481. holyDay: holyDay$8,
  1482. weekdayL: weekdayL$8,
  1483. BE: BE$8,
  1484. badiCalendar: badiCalendar$8
  1485. });
  1486. const month$3 = {
  1487. 1: 'Бахā',
  1488. 2: 'Джалāл',
  1489. 3: 'Джамāл',
  1490. 4: '‘Аз̣амат',
  1491. 5: 'Нӯр',
  1492. 6: 'Рах̣мат',
  1493. 7: 'Калимāт',
  1494. 8: 'Камāл',
  1495. 9: 'Асмā’',
  1496. 10: '‘Иззат',
  1497. 11: 'Машӣййат',
  1498. 12: '‘Илм',
  1499. 13: 'К̣удрат',
  1500. 14: 'К̣аул',
  1501. 15: 'Масā’ил',
  1502. 16: 'Шараф',
  1503. 17: 'Султ̣ан',
  1504. 18: 'Мулк',
  1505. 19: '‘Алā’',
  1506. 20: 'Аййāм-и Хā',
  1507. };
  1508. const monthL$9 = {
  1509. 1: 'Великолепие',
  1510. 2: 'Слава',
  1511. 3: 'Красота',
  1512. 4: 'Величие',
  1513. 5: 'Свет',
  1514. 6: 'Милость',
  1515. 7: 'Слова',
  1516. 8: 'Совершенство',
  1517. 9: 'Имена',
  1518. 10: 'Мощь',
  1519. 11: 'Воля',
  1520. 12: 'Знание',
  1521. 13: 'Могущество',
  1522. 14: 'Речь',
  1523. 15: 'Вопросы',
  1524. 16: 'Честь',
  1525. 17: 'Владычество',
  1526. 18: 'Господство',
  1527. 19: 'Возвышенность',
  1528. 20: 'Аййāм-и Хā',
  1529. };
  1530. const holyDay$9 = {
  1531. 1: 'Нау-Рӯз',
  1532. 2: '1-й день Рид̣вāна',
  1533. 3: '9-й день Рид̣вāна',
  1534. 4: '12-й день Рид̣вāна',
  1535. 5: 'Возвещение Баба',
  1536. 6: 'Вознесение Бахауллы',
  1537. 7: 'Мученическая Баба',
  1538. 8: 'рождения Баба',
  1539. 9: 'рождения Бахауллы',
  1540. 10: 'День Завета',
  1541. 11: 'Вознесение Абдул-Баха',
  1542. };
  1543. const weekday$3 = {
  1544. 1: 'Джалāл',
  1545. 2: 'Джамāл',
  1546. 3: 'Камāл',
  1547. 4: 'Фид̣āл',
  1548. 5: '‘Идāл',
  1549. 6: 'Истиджлāл',
  1550. 7: 'Истик̣лāл',
  1551. };
  1552. const weekdayAbbr3$3 = {
  1553. 1: 'Джл',
  1554. 2: 'Джм',
  1555. 3: 'Кам',
  1556. 4: 'Фид̣',
  1557. 5: '‘Идā',
  1558. 6: 'Исд',
  1559. 7: 'Иск̣',
  1560. };
  1561. const weekdayAbbr2$3 = {
  1562. 1: 'Дл',
  1563. 2: 'Дм',
  1564. 3: 'Ка',
  1565. 4: 'Фи',
  1566. 5: '‘Ид',
  1567. 6: 'Ид',
  1568. 7: 'Ик̣',
  1569. };
  1570. const weekdayL$9 = {
  1571. 1: 'Слава',
  1572. 2: 'Красота',
  1573. 3: 'Совершенство',
  1574. 4: 'Благодать',
  1575. 5: 'Справедливость',
  1576. 6: 'Величие',
  1577. 7: 'Независимость',
  1578. };
  1579. const yearInVahid$3 = {
  1580. 1: 'Алиф',
  1581. 2: 'Бā’',
  1582. 3: 'Аб',
  1583. 4: 'Дāл',
  1584. 5: 'Бāб',
  1585. 6: 'Вāв',
  1586. 7: 'Абад',
  1587. 8: 'Джāд',
  1588. 9: 'Бахā',
  1589. 10: 'Х̣убб',
  1590. 11: 'Баххāдж',
  1591. 12: 'Джавāб',
  1592. 13: 'Ах̣ад',
  1593. 14: 'Ваххāб',
  1594. 15: 'Видāд',
  1595. 16: 'Бадӣ‘',
  1596. 17: 'Бахӣ',
  1597. 18: 'Абхā',
  1598. 19: 'Вāх̣ид',
  1599. };
  1600. const vahid$3 = 'Вāх̣ид';
  1601. const kulliShay$3 = 'кулл-и шай’';
  1602. const BE$9 = 'Э.Б.';
  1603. const badiCalendar$9 = 'Календарь Бадӣ‘';
  1604. var ru = /*#__PURE__*/Object.freeze({
  1605. __proto__: null,
  1606. month: month$3,
  1607. monthL: monthL$9,
  1608. holyDay: holyDay$9,
  1609. weekday: weekday$3,
  1610. weekdayAbbr3: weekdayAbbr3$3,
  1611. weekdayAbbr2: weekdayAbbr2$3,
  1612. weekdayL: weekdayL$9,
  1613. yearInVahid: yearInVahid$3,
  1614. vahid: vahid$3,
  1615. kulliShay: kulliShay$3,
  1616. BE: BE$9,
  1617. badiCalendar: badiCalendar$9
  1618. });
  1619. const monthL$a = {
  1620. 1: 'Praktfullhet',
  1621. 2: 'Härlighet',
  1622. 3: 'Skönhet',
  1623. 4: 'Storhet',
  1624. 5: 'Ljus',
  1625. 6: 'Barmhärtighet',
  1626. 7: 'Ord',
  1627. 8: 'Fullkomlighet',
  1628. 9: 'Namn',
  1629. 10: 'Makt',
  1630. 11: 'Vilja',
  1631. 12: 'Kunskap',
  1632. 13: 'Kraft',
  1633. 14: 'Tal',
  1634. 15: 'Frågor',
  1635. 16: 'Ära',
  1636. 17: 'Överhöghet',
  1637. 18: 'Herravälde',
  1638. 19: 'Upphöjdhet',
  1639. 20: 'Ayyám-i-Há',
  1640. };
  1641. const holyDay$a = {
  1642. 1: 'Naw-Rúz',
  1643. 2: 'Första Riḍván',
  1644. 3: 'Nionde Riḍván',
  1645. 4: 'Tolfte Riḍván',
  1646. 5: 'Bábs Deklaration',
  1647. 6: 'Bahá’u’lláhs Bortgång',
  1648. 7: 'Bábs Martyrskap',
  1649. 8: 'Bábs Födelse',
  1650. 9: 'Bahá’u’lláhs Födelse',
  1651. 10: 'Förbundets dag',
  1652. 11: '‘Abdu’l-Bahás Bortgång',
  1653. };
  1654. const weekdayL$a = {
  1655. 1: 'Härlighet',
  1656. 2: 'Skönhet',
  1657. 3: 'Fullkomlighet',
  1658. 4: 'Nåd',
  1659. 5: 'Rättvisa',
  1660. 6: 'Majestät',
  1661. 7: 'Oberoende',
  1662. };
  1663. const BE$a = 'B.E.';
  1664. const badiCalendar$a = 'Badí‘kalendern';
  1665. var sv = /*#__PURE__*/Object.freeze({
  1666. __proto__: null,
  1667. monthL: monthL$a,
  1668. holyDay: holyDay$a,
  1669. weekdayL: weekdayL$a,
  1670. BE: BE$a,
  1671. badiCalendar: badiCalendar$a
  1672. });
  1673. const month$4 = {
  1674. 1: '巴哈',
  1675. 2: '贾拉勒',
  1676. 3: '贾迈勒',
  1677. 4: '阿泽迈特',
  1678. 5: '努尔',
  1679. 6: '拉赫迈特',
  1680. 7: '凯利马特',
  1681. 8: '卡迈勒',
  1682. 9: '艾斯玛',
  1683. 10: '伊扎特',
  1684. 11: '迈希耶特',
  1685. 12: '伊勒姆',
  1686. 13: '古德雷特',
  1687. 14: '高勒',
  1688. 15: '迈萨伊勒',
  1689. 16: '谢拉夫',
  1690. 17: '苏丹',
  1691. 18: '穆勒克',
  1692. 19: '阿拉',
  1693. 20: '阿亚米哈',
  1694. };
  1695. const monthL$b = {
  1696. 1: '耀',
  1697. 2: '辉',
  1698. 3: '美',
  1699. 4: '宏',
  1700. 5: '光',
  1701. 6: '仁',
  1702. 7: '言',
  1703. 8: '完',
  1704. 9: '名',
  1705. 10: '能',
  1706. 11: '意',
  1707. 12: '知',
  1708. 13: '力',
  1709. 14: '语',
  1710. 15: '问',
  1711. 16: '尊',
  1712. 17: '权',
  1713. 18: '统',
  1714. 19: '崇',
  1715. 20: '哈之日',
  1716. };
  1717. const holyDay$b = {
  1718. 1: '诺鲁孜节',
  1719. 2: '里兹万节第一日',
  1720. 3: '里兹万节第九日',
  1721. 4: '里兹万节第十二日',
  1722. 5: '巴孛宣示日',
  1723. 6: '巴哈欧拉升天日',
  1724. 7: '巴孛殉道日',
  1725. 8: '巴孛诞辰',
  1726. 9: '巴哈欧拉诞辰',
  1727. 10: '圣约日',
  1728. 11: '阿博都-巴哈升天日',
  1729. };
  1730. const weekday$4 = {
  1731. 1: '贾拉勒',
  1732. 2: '贾迈勒',
  1733. 3: '卡迈勒',
  1734. 4: '菲达勒',
  1735. 5: '伊达勒',
  1736. 6: '伊斯提杰拉勒',
  1737. 7: '伊斯提格拉勒',
  1738. };
  1739. const weekdayAbbr3$4 = {
  1740. 1: '贾拉勒',
  1741. 2: '贾迈勒',
  1742. 3: '卡迈勒',
  1743. 4: '菲达勒',
  1744. 5: '伊达勒',
  1745. 6: '伊斯杰',
  1746. 7: '伊斯格',
  1747. };
  1748. const weekdayAbbr2$4 = {
  1749. 1: '贾拉',
  1750. 2: '贾迈',
  1751. 3: '卡迈',
  1752. 4: '菲达',
  1753. 5: '伊达',
  1754. 6: '伊杰',
  1755. 7: '伊格',
  1756. };
  1757. const weekdayL$b = {
  1758. 1: '辉日',
  1759. 2: '美日',
  1760. 3: '完日',
  1761. 4: '恩日',
  1762. 5: '正日',
  1763. 6: '威日',
  1764. 7: '独日',
  1765. };
  1766. const yearInVahid$4 = {
  1767. 1: '艾利夫',
  1768. 2: '巴',
  1769. 3: '艾卜',
  1770. 4: '达勒',
  1771. 5: '巴卜',
  1772. 6: '瓦乌',
  1773. 7: '阿巴德',
  1774. 8: '贾德',
  1775. 9: '巴哈',
  1776. 10: '胡卜',
  1777. 11: '巴哈杰',
  1778. 12: '贾瓦卜',
  1779. 13: '阿哈德',
  1780. 14: '瓦哈卜',
  1781. 15: '维达德',
  1782. 16: '巴迪',
  1783. 17: '巴希',
  1784. 18: '阿卜哈',
  1785. 19: '瓦希德',
  1786. };
  1787. const vahid$4 = '瓦希德';
  1788. const kulliShay$4 = '库里沙伊';
  1789. const BE$b = 'BE';
  1790. const badiCalendar$b = '巴迪历';
  1791. var zh = /*#__PURE__*/Object.freeze({
  1792. __proto__: null,
  1793. month: month$4,
  1794. monthL: monthL$b,
  1795. holyDay: holyDay$b,
  1796. weekday: weekday$4,
  1797. weekdayAbbr3: weekdayAbbr3$4,
  1798. weekdayAbbr2: weekdayAbbr2$4,
  1799. weekdayL: weekdayL$b,
  1800. yearInVahid: yearInVahid$4,
  1801. vahid: vahid$4,
  1802. kulliShay: kulliShay$4,
  1803. BE: BE$b,
  1804. badiCalendar: badiCalendar$b
  1805. });
  1806. const monthL$c = {
  1807. 1: 'Splendor',
  1808. 16: 'Honor',
  1809. };
  1810. var en_us = /*#__PURE__*/Object.freeze({
  1811. __proto__: null,
  1812. monthL: monthL$c
  1813. });
  1814. /* eslint-disable dot-notation, line-comment-position, camelcase, sort-imports */
  1815. const badiLocale = { en, ar, de, es, fa, fr, lv, nl, pt, ru, sv, zh, 'en-us': en_us, default: en };
  1816. const setDefaultLanguage = (language) => {
  1817. if (badiLocale[language] === undefined) {
  1818. // eslint-disable-next-line no-console
  1819. console.log('Chosen language does not exist. Setting has not been changed.');
  1820. }
  1821. else {
  1822. badiLocale['default'] = badiLocale[language];
  1823. }
  1824. };
  1825. let underlineFormat = 'css';
  1826. const setUnderlineFormat = (format) => {
  1827. if (['css', 'u', 'diacritic', 'none'].includes(format)) {
  1828. underlineFormat = format;
  1829. }
  1830. else {
  1831. // eslint-disable-next-line no-console
  1832. console.log('Invalid underline format. Choose one of ["css", "u", "diacritic", "none"]. ' +
  1833. 'Setting has not been changed.');
  1834. }
  1835. };
  1836. const formatTokens = [
  1837. ['DDL', 'DD+', 'MML', 'MM+', 'WWL', 'yyv', 'KiS'],
  1838. ['dd', 'DD', 'mm', 'MM', 'ww', 'WW', 'yv', 'YV', 'vv', 'kk', 'yy', 'BE', 'BC', 'Va'],
  1839. ['d', 'D', 'm', 'M', 'W', 'v', 'k', 'y']
  1840. ];
  1841. // eslint-disable-next-line complexity
  1842. const formatBadiDate = (badiDate, formatString, language) => {
  1843. if (!badiDate.isValid) {
  1844. return 'Not a valid Badí‘ date';
  1845. }
  1846. if (typeof language === 'string' && badiLocale[language] === undefined && language.includes('-')) {
  1847. language = language.split('-')[0];
  1848. }
  1849. if (language === undefined || badiLocale[language] === undefined) {
  1850. language = 'default';
  1851. }
  1852. formatString = formatString !== null && formatString !== void 0 ? formatString : formatItemFallback(language, 'defaultFormat');
  1853. let formattedDate = '';
  1854. const length = formatString.length;
  1855. for (let i = 0; i < length; i++) {
  1856. // Text wrapped in {} is output as-is. A '{' without a matching '}'
  1857. // results in invalid input
  1858. if (formatString[i] === '{' && i < length - 1) {
  1859. for (let j = i + 1; j <= length; j++) {
  1860. if (j === length) {
  1861. return 'Invalid formatting string.';
  1862. }
  1863. if (formatString[j] === '}') {
  1864. i = j;
  1865. break;
  1866. }
  1867. formattedDate += formatString[j];
  1868. }
  1869. }
  1870. else {
  1871. const next1 = formatString[i];
  1872. const next2 = next1 + formatString[i + 1];
  1873. const next3 = next2 + formatString[i + 2];
  1874. if (formatTokens[0].includes(next3)) {
  1875. formattedDate += getFormatItem(badiDate, next3, language);
  1876. i += 2;
  1877. }
  1878. else if (formatTokens[1].includes(next2)) {
  1879. formattedDate += getFormatItem(badiDate, next2, language);
  1880. i += 1;
  1881. }
  1882. else if (formatTokens[2].includes(next1)) {
  1883. formattedDate += getFormatItem(badiDate, next1, language);
  1884. }
  1885. else {
  1886. formattedDate += next1;
  1887. }
  1888. }
  1889. }
  1890. return formattedDate;
  1891. };
  1892. // eslint-disable-next-line complexity
  1893. const getFormatItem = (badiDate, token, language) => {
  1894. switch (token) {
  1895. // Single character tokens
  1896. case 'd':
  1897. return digitRewrite(badiDate.day, language);
  1898. case 'D':
  1899. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day), 3);
  1900. case 'm':
  1901. return digitRewrite(badiDate.month, language);
  1902. case 'M':
  1903. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month), 3);
  1904. case 'W':
  1905. return formatItemFallback(language, 'weekdayAbbr3', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1906. case 'y':
  1907. return digitRewrite(badiDate.year, language);
  1908. case 'v':
  1909. return digitRewrite((Math.floor((badiDate.year - 1) / 19) % 19) + 1, language);
  1910. case 'k':
  1911. return digitRewrite(Math.floor((badiDate.year - 1) / 361) + 1, language);
  1912. // Two character tokens
  1913. case 'dd':
  1914. return digitRewrite((`0${String(badiDate.day)}`).slice(-2), language);
  1915. case 'DD':
  1916. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day));
  1917. case 'mm':
  1918. return digitRewrite((`0${String(badiDate.month)}`).slice(-2), language);
  1919. case 'MM':
  1920. return postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month));
  1921. case 'ww':
  1922. return formatItemFallback(language, 'weekdayAbbr2', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1923. case 'WW':
  1924. return formatItemFallback(language, 'weekday', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1925. case 'yy':
  1926. return digitRewrite((`00${String(badiDate.year)}`).slice(-3), language);
  1927. case 'yv':
  1928. return digitRewrite((badiDate.year - 1) % 19 + 1, language);
  1929. case 'YV':
  1930. return formatItemFallback(language, 'yearInVahid', (badiDate.year - 1) % 19 + 1);
  1931. case 'vv':
  1932. return digitRewrite((`0${String((Math.floor((badiDate.year - 1) / 19) + 2) % 19 - 1)}`).slice(-2), language);
  1933. case 'kk':
  1934. return digitRewrite((`0${String(Math.floor((badiDate.year - 1) / 361) + 1)}`).slice(-2), language);
  1935. case 'Va':
  1936. return formatItemFallback(language, 'vahid');
  1937. case 'BE':
  1938. return formatItemFallback(language, 'BE');
  1939. case 'BC':
  1940. return formatItemFallback(language, 'badiCalendar');
  1941. // Three character tokens
  1942. case 'DDL':
  1943. return formatItemFallback(language, 'monthL', badiDate.day);
  1944. case 'DD+': {
  1945. const day = postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.day));
  1946. const dayL = formatItemFallback(language, 'monthL', badiDate.day);
  1947. if (day === dayL) {
  1948. return day;
  1949. }
  1950. if (badiLocale[language] === badiLocale.fa) {
  1951. return `<span dir="rtl">${day} (${dayL})</span>`;
  1952. }
  1953. return `${day} (${dayL})`;
  1954. }
  1955. case 'MML':
  1956. return formatItemFallback(language, 'monthL', badiDate.month);
  1957. case 'MM+': {
  1958. const month = postProcessLocaleItem(formatItemFallback(language, 'month', badiDate.month));
  1959. const monthL = formatItemFallback(language, 'monthL', badiDate.month);
  1960. if (month === monthL) {
  1961. return month;
  1962. }
  1963. if (badiLocale[language] === badiLocale.fa) {
  1964. return `<span dir="rtl">${month} (${monthL})</span>`;
  1965. }
  1966. return `${month} (${monthL})`;
  1967. }
  1968. case 'WWL':
  1969. return formatItemFallback(language, 'weekdayL', (badiDate.gregorianDate.weekday + 1) % 7 + 1);
  1970. case 'yyv':
  1971. return digitRewrite((`0${String((badiDate.year - 1) % 19 + 1)}`).slice(-2), language);
  1972. case 'KiS':
  1973. return postProcessLocaleItem(formatItemFallback(language, 'kulliShay'));
  1974. // istanbul ignore next
  1975. default:
  1976. return '';
  1977. }
  1978. };
  1979. const postProcessLocaleItem = (item, crop) => {
  1980. if (crop && crop < item.length) {
  1981. let char = 0;
  1982. let counter = 0;
  1983. while (counter < crop) {
  1984. if (!'_’‘'.includes(item[char])) {
  1985. counter++;
  1986. }
  1987. char++;
  1988. }
  1989. if ('_’‘'.includes(item[char])) {
  1990. char++;
  1991. }
  1992. item = item.slice(0, char);
  1993. if (item.split('_').length % 2 === 0) {
  1994. item += '_';
  1995. }
  1996. }
  1997. const stringComponents = item.split('_');
  1998. for (let i = 1; i < stringComponents.length; i += 2) {
  1999. stringComponents[i] = underlineString(stringComponents[i]);
  2000. }
  2001. return stringComponents.join('');
  2002. };
  2003. const underlineString = (str) => {
  2004. switch (underlineFormat) {
  2005. case 'css':
  2006. return `<span style="text-decoration:underline">${str}</span>`;
  2007. case 'diacritic':
  2008. return str.split('').map(char => `${char}\u0332`).join('');
  2009. case 'u':
  2010. return `<u>${str}</u>`;
  2011. case 'none':
  2012. return str;
  2013. // istanbul ignore next
  2014. default:
  2015. throw new TypeError('Unexpected underlineFormat');
  2016. }
  2017. };
  2018. const digitRewrite = (number, language) => {
  2019. number = String(number);
  2020. const unicodeOffset = formatItemFallback(language, 'unicodeCharForZero').charCodeAt(0) - '0'.charCodeAt(0);
  2021. if (unicodeOffset === 0) {
  2022. return number;
  2023. }
  2024. const codePoints = [...number].map(num => num.charCodeAt(0) + unicodeOffset);
  2025. return String.fromCharCode(...codePoints);
  2026. };
  2027. const formatItemFallback = (language, category, index) => {
  2028. var _a;
  2029. if (index === undefined) {
  2030. while (badiLocale[language][category] === undefined) {
  2031. language = languageFallback(language);
  2032. }
  2033. return badiLocale[language][category];
  2034. }
  2035. while (((_a = badiLocale[language][category]) === null || _a === void 0 ? void 0 : _a[index]) === undefined) {
  2036. language = languageFallback(language);
  2037. }
  2038. return badiLocale[language][category][index];
  2039. };
  2040. const languageFallback = (languageCode) => {
  2041. if (languageCode.includes('-')) {
  2042. return languageCode.split('-')[0];
  2043. // eslint-disable-next-line no-negated-condition
  2044. }
  2045. else if (languageCode !== 'default') {
  2046. return 'default';
  2047. }
  2048. return 'en';
  2049. };
  2050. const badiYears = [
  2051. 'l4da', 'k4ci', 'k5c7', 'l4d6', 'l4ce', 'k4c4', 'k5d4', 'l4cb', 'l4c1', 'k4cj', 'k5c8', 'l4d7', 'l4cf', 'k4c5',
  2052. 'k4d5', 'k5ce', 'l4c2', 'k4d2', 'k4ca', 'k5da', 'l4ch', 'k4c6', 'k4d6', 'k5cf', 'l4c4', 'k4d4', 'k4cc', 'k5c1',
  2053. 'l4cj', 'k4c8', 'k4d8', 'k5cg', 'l4c5', 'k4d5', 'k4ce', 'k5c3', 'l4d2', 'k4ca', 'k4d9', 'k5ci', 'l4c6', 'k4d6',
  2054. 'k4cf', 'k4c4', 'k5d4', 'k4cb', 'k4bj', 'k4cj', 'k5c9', 'k4d8', 'k4cg', 'k4c6', 'k5d6', 'k4cd', 'k4c2', 'k4d2',
  2055. 'k5ca', 'k4d9', 'k4ci', 'k4c7', 'k5d7', 'k4cf', 'k4c4', 'k4d4', 'k5cc', 'k4bj', 'k4cj', 'k4c9', 'k5d9', 'k4cg',
  2056. 'k4c6', 'k4d5', 'k5cd', 'k4c2', 'k4d1', 'k4ca', 'k4da', 'j5cj', 'k4c7', 'k4d7', 'k4cf', 'j5c4', 'k4d3', 'k4cb',
  2057. 'k4c1', 'k5d1', 'l4c9', 'l4d9', 'l4ch', 'k5c6', 'l4d5', 'l4cd', 'l4c2', 'k5d2', 'l4ca', 'l4da', 'l4cj', 'k5c8',
  2058. 'l4d7', 'l4cf', 'l4c4', 'k5d4', 'l4cb', 'l4c1', 'l4d1', 'k5c9', 'l4d8', 'l4cg', 'l4c5', 'k4d5', 'k5ce', 'l4c2',
  2059. 'l4d2', 'k4cb', 'k5db', 'l4ci', 'l4c7', 'k4d7', 'k5cf', 'l4c4', 'l4d4', 'k4cc', 'k5c2', 'l4d1', 'l4c9', 'k4d9',
  2060. 'k5ch', 'l4c5', 'l4d5', 'k4ce', 'k5c3', 'l4d2', 'l4cb', 'k4da', 'k5ci', 'l4c6', 'l4d6', 'k4cf', 'k5c5', 'l4d4',
  2061. 'l4cc', 'k4c1', 'k4d1', 'k5c9', 'l4d8', 'k4cg', 'k4c6', 'k5d6', 'l4ce', 'k4c3', 'k4d3', 'k5cb', 'l4da', 'k4ci',
  2062. 'k4c7', 'k5d7', 'l4cf', 'k4c5', 'k4d5', 'k5cd', 'l4c1', 'k4cj', 'k4c9', 'k5d9', 'l4cg', 'k4c6', 'k4d6', 'k5ce',
  2063. 'l4c3', 'k4d2', 'k4ca', 'k5bj', 'l4ci', 'k4c7', 'k4d7', 'k4cg', 'k5c5', 'k4d4', 'k4cc', 'k4c1', 'k5d1', 'k4c9',
  2064. 'k4d9', 'k4ch', 'k5c7', 'l4d6', 'l4ce', 'l4c3', 'l5d3', 'l4ca', 'l4da', 'l4cj', 'l5c8', 'l4d7', 'l4cg', 'l4c5',
  2065. 'l5d4', 'l4cb', 'l4c1', 'l4d1', 'l5ca', 'l4d9', 'l4ch', 'l4c6', 'l5d6', 'l4cd', 'l4c2', 'l4d2', 'l4cb', 'k5c1',
  2066. 'l4cj', 'l4c8', 'l4d8', 'k5cg', 'l4c4', 'l4d4', 'l4cc', 'k5c2', 'l4d1', 'l4ca', 'l4da', 'k5ci', 'l4c6', 'l4d5',
  2067. 'l4ce', 'k5c3', 'l4d2', 'l4cb', 'l4db', 'k5cj', 'l4c8', 'l4d7', 'l4cf', 'k5c5', 'l4d4', 'l4cc', 'l4c2', 'k5d2',
  2068. 'l4c9', 'l4d9', 'l4ch', 'k4c6', 'k5d6', 'l4ce', 'l4c3', 'k4d3', 'k5cc', 'l4db', 'l4cj', 'k4c8', 'k5d8', 'l4cf',
  2069. 'l4c4', 'k4d5', 'k5cd', 'l4c2', 'l4d2', 'k4ca', 'k5d9', 'l4cg', 'l4c6', 'k4d6', 'k5cf', 'l4c3', 'l4d3', 'k4cb',
  2070. 'k5bj', 'l4ci', 'l4c7', 'k4d7', 'k5cg', 'l4c5', 'l4d5', 'k4cd', 'k4c2', 'k5d2', 'l4c9', 'k4d9', 'k4ch', 'k5c7',
  2071. 'l4d6', 'k4cf', 'k4c4', 'k5d4', 'l4cb', 'l4bj', 'l4cj', 'l5c8', 'm4d7', 'l4cg', 'l4c5', 'l5d5', 'm4cc', 'l4c1',
  2072. 'l4d1', 'l5ca', 'm4d9', 'l4ch', 'l4c7', 'l5d7', 'm4ce', 'l4c3', 'l4d3', 'l5cb', 'm4bi', 'l4ci', 'l4c8', 'l4d8',
  2073. 'l5ch', 'l4c5', 'l4d5', 'l4cd', 'l5c2', 'l4d1', 'l4c9', 'l4da', 'l5ci', 'l4c7', 'l4d7', 'l4cf', 'l5c4', 'l4d2',
  2074. 'l4cb', 'l4bj', 'l5d1', 'l4c8', 'l4d8', 'l4cg', 'l5c5', 'l4d4', 'l4cc', 'l4c2', 'l5d2', 'l4c9', 'l4da', 'l4ci',
  2075. ];
  2076. class BadiDate {
  2077. constructor(date) {
  2078. this._holyDay = undefined;
  2079. this._valid = true;
  2080. this._invalidReason = undefined;
  2081. try {
  2082. if (this._isDateObject(date)) {
  2083. this._gregorianDate = DateTime.fromObject({ year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate(), zone: 'UTC' });
  2084. }
  2085. else if (DateTime.isDateTime(date)) {
  2086. this._gregorianDate = DateTime.fromObject({ year: date.year, month: date.month, day: date.day, zone: 'UTC' });
  2087. }
  2088. else if (this._isYearMonthDay(date) || this._isYearHolyDayNumber(date)) {
  2089. this._setFromBadiDate(date);
  2090. }
  2091. else {
  2092. throw new TypeError('Unrecognized input format');
  2093. }
  2094. if (this._year === undefined) {
  2095. // We haven't set the Badí' date yet
  2096. this._setFromGregorianDate();
  2097. }
  2098. this._setHolyDay();
  2099. }
  2100. catch (err) {
  2101. this._setInvalid(err);
  2102. }
  2103. Object.freeze(this);
  2104. }
  2105. format(formatString, language) {
  2106. return formatBadiDate(this, formatString, language);
  2107. }
  2108. _isDateObject(arg) {
  2109. return Object.prototype.toString.call(arg) === '[object Date]';
  2110. }
  2111. _isYearMonthDay(arg) {
  2112. return typeof arg.year === 'number' && typeof arg.month === 'number' &&
  2113. typeof arg.day === 'number';
  2114. }
  2115. _isYearHolyDayNumber(arg) {
  2116. return typeof arg.year === 'number' && arg.month === undefined &&
  2117. arg.day === undefined && typeof arg.holyDayNumber === 'number';
  2118. }
  2119. _notInValidGregorianDateRange(datetime) {
  2120. const lowerBound = DateTime.fromObject({ year: 1844, month: 3, day: 21, zone: 'UTC' });
  2121. const upperBound = DateTime.fromObject({ year: 2351, month: 3, day: 20, zone: 'UTC' });
  2122. return datetime < lowerBound || datetime > upperBound;
  2123. }
  2124. _setFromGregorianDate() {
  2125. if (this._notInValidGregorianDateRange(this._gregorianDate)) {
  2126. throw new RangeError('Input date outside of valid range (1844-03-21 - 2351-03-20)');
  2127. }
  2128. const gregorianYear = this._gregorianDate.year;
  2129. const oldImplementationCutoff = DateTime.fromObject({ year: 2015, month: 3, day: 21, zone: 'UTC' });
  2130. if (this._gregorianDate < oldImplementationCutoff) {
  2131. const { month, day } = this._gregorianDate;
  2132. if (month < 3 || (month === 3 && day < 21)) {
  2133. this._nawRuz = DateTime.fromObject({ year: gregorianYear - 1, month: 3, day: 21, zone: 'UTC' });
  2134. this._year = gregorianYear - 1844;
  2135. }
  2136. else {
  2137. this._nawRuz = DateTime.fromObject({ year: gregorianYear, month: 3, day: 21, zone: 'UTC' });
  2138. this._year = gregorianYear - 1843;
  2139. }
  2140. this._setOldAyyamiHaLength();
  2141. this._yearTwinBirthdays = [12, 5, 13, 9];
  2142. }
  2143. else {
  2144. this._year = gregorianYear - 1843;
  2145. this._setBadiYearInfo(true);
  2146. }
  2147. this._setBadiMonthAndDay();
  2148. }
  2149. /**
  2150. * Set Badí' month and day from Gregorian date
  2151. */
  2152. _setBadiMonthAndDay() {
  2153. const dayOfBadiYear = this._dayOfYear(this._gregorianDate);
  2154. if (dayOfBadiYear < 343) {
  2155. this._month = Math.floor((dayOfBadiYear - 1) / 19 + 1);
  2156. this._day = (dayOfBadiYear - 1) % 19 + 1;
  2157. }
  2158. else if (dayOfBadiYear < 343 + this._ayyamiHaLength) {
  2159. this._month = 20;
  2160. this._day = dayOfBadiYear - 342;
  2161. }
  2162. else {
  2163. this._month = 19;
  2164. this._day = dayOfBadiYear - (342 + this._ayyamiHaLength);
  2165. }
  2166. }
  2167. _setFromBadiDate(date) {
  2168. this._year = date.year;
  2169. if (this._year < 1 || this._year > 507) {
  2170. throw new RangeError('Input date outside of valid range (1 - 507 B.E.)');
  2171. }
  2172. else if (this._year < 172) {
  2173. this._nawRuz = DateTime.fromObject({ year: 1843 + this._year, month: 3, day: 21, zone: 'UTC' });
  2174. this._setOldAyyamiHaLength();
  2175. this._yearTwinBirthdays = [12, 5, 13, 9];
  2176. }
  2177. else {
  2178. this._setBadiYearInfo();
  2179. }
  2180. if (this._isYearMonthDay(date)) {
  2181. this._month = date.month;
  2182. this._day = date.day;
  2183. if (this._month === 20 && this._day > this._ayyamiHaLength) {
  2184. // If only off by one day, we'll bubble up so that 5th Ayyám-i-Há in a year with only 4 days of
  2185. // Ayyám-i-Há can be salvaged
  2186. if (this._day - this._ayyamiHaLength === 1) {
  2187. this._month = 19;
  2188. this._day = 1;
  2189. }
  2190. else {
  2191. throw new TypeError('Input numbers do not designate a valid date');
  2192. }
  2193. }
  2194. if (this._month < 1 || this._month > 20 || this._day < 1 || this.day > 19) {
  2195. throw new TypeError('Input numbers do not designate a valid date');
  2196. }
  2197. }
  2198. else {
  2199. if (date.holyDayNumber < 1 || date.holyDayNumber > 11) {
  2200. throw new TypeError('Input numbers do not designate a valid Holy Day');
  2201. }
  2202. this._holyDay = date.holyDayNumber;
  2203. [this._month, this._day] = this._holyDayMapping()[this._holyDay];
  2204. }
  2205. this._gregorianDate = this._nawRuz.plus(Duration.fromObject({ days: this._dayOfYear([this._year, this._month, this._day]) - 1 }));
  2206. }
  2207. _setOldAyyamiHaLength() {
  2208. if (DateTime.fromObject({ year: this._nawRuz.year + 1 }).isInLeapYear) {
  2209. this._ayyamiHaLength = 5;
  2210. }
  2211. else {
  2212. this._ayyamiHaLength = 4;
  2213. }
  2214. }
  2215. _setBadiYearInfo(fromGregorianDate = false) {
  2216. let yearData = this._extractBadiYearInfo();
  2217. if (fromGregorianDate && this._gregorianDate < yearData.nawRuz) {
  2218. this._year -= 1;
  2219. yearData = this._extractBadiYearInfo();
  2220. }
  2221. this._nawRuz = yearData.nawRuz;
  2222. this._ayyamiHaLength = yearData.ayyamiHaLength;
  2223. this._yearTwinBirthdays = yearData.twinBirthdays;
  2224. }
  2225. _extractBadiYearInfo() {
  2226. let nawRuz, ayyamiHaLength, twinBirthdays;
  2227. // Check whether data needs to be unpacked or exists in the verbose version
  2228. // istanbul ignore else
  2229. if (badiYears[0] === 'l4da') {
  2230. const components = badiYears[this._year - 172].split('');
  2231. nawRuz = DateTime.fromObject({ year: this._year - 172 + 2015, month: 3, day: parseInt(components[0], 36), zone: 'UTC' });
  2232. ayyamiHaLength = parseInt(components[1], 36);
  2233. const TB1 = [parseInt(components[2], 36), parseInt(components[3], 36)];
  2234. const TB2 = TB1[1] < 19 ? [TB1[0], TB1[1] + 1] : [TB1[0] + 1, 1];
  2235. twinBirthdays = [TB1[0], TB1[1], TB2[0], TB2[1]];
  2236. }
  2237. else {
  2238. ({ nawRuz, ayyamiHaLength, twinBirthdays } = badiYears[this._year]);
  2239. nawRuz = DateTime.fromISO(nawRuz, { zone: 'UTC' });
  2240. }
  2241. return { nawRuz, ayyamiHaLength, twinBirthdays };
  2242. }
  2243. _dayOfYear(date) {
  2244. // Naw-Rúz is day 1
  2245. if (Array.isArray(date)) {
  2246. // We have a Badí' date
  2247. if (date[1] < 19) {
  2248. return 19 * (date[1] - 1) + date[2];
  2249. }
  2250. else if (date[1] === 20) {
  2251. return 342 + date[2];
  2252. }
  2253. // date[1] === 19
  2254. return 342 + this._ayyamiHaLength + date[2];
  2255. }
  2256. return date.diff(this._nawRuz).as('days') + 1;
  2257. }
  2258. _setInvalid(invalidReason) {
  2259. this._gregorianDate = DateTime.invalid('Not a valid Badí‘ date');
  2260. this._year = NaN;
  2261. this._month = NaN;
  2262. this._day = NaN;
  2263. this._ayyamiHaLength = NaN;
  2264. this._nawRuz = DateTime.invalid('Not a valid Badí‘ date');
  2265. this._valid = false;
  2266. this._invalidReason = invalidReason;
  2267. }
  2268. _setHolyDay() {
  2269. const mapping = this._holyDayMapping();
  2270. this._holyDay = parseInt(Object.keys(mapping)
  2271. .find(key => mapping[key][0] === this._month && mapping[key][1] === this._day), 10);
  2272. }
  2273. _holyDayMapping() {
  2274. return {
  2275. [1 /* NawRuz */]: [1, 1],
  2276. [2 /* FirstRidvan */]: [2, 13],
  2277. [3 /* NinthRidvan */]: [3, 2],
  2278. [4 /* TwelfthRidvan */]: [3, 5],
  2279. [5 /* DeclarationOfTheBab */]: [4, this._year < 172 ? 7 : 8],
  2280. [6 /* AscensionOfBahaullah */]: [4, 13],
  2281. [7 /* MartyrdomOfTheBab */]: [6, this._year < 172 ? 16 : 17],
  2282. [8 /* BirthOfTheBab */]: [this._yearTwinBirthdays[0], this._yearTwinBirthdays[1]],
  2283. [9 /* BirthOfBahaullah */]: [this._yearTwinBirthdays[2], this._yearTwinBirthdays[3]],
  2284. [10 /* DayOfTheCovenant */]: [14, 4],
  2285. [11 /* AscensionOfAbdulBaha */]: [14, 6],
  2286. };
  2287. }
  2288. _leapYearsBefore() {
  2289. let leapYearsBefore = Math.floor(Math.min(this.year - 1, 171) / 4);
  2290. if (this.year > 172) {
  2291. // istanbul ignore else
  2292. if (badiYears[0] === 'l4da') {
  2293. leapYearsBefore += badiYears.slice(0, this.year - 172).filter(entry => entry[1] === '5').length;
  2294. }
  2295. else {
  2296. leapYearsBefore += Object.entries(badiYears)
  2297. .filter(([year, data]) => parseInt(year, 10) < this.year &&
  2298. data.ayyamiHaLength === 5).length;
  2299. }
  2300. }
  2301. return leapYearsBefore;
  2302. }
  2303. holyDay(language = undefined) {
  2304. if (!this._holyDay) {
  2305. return '';
  2306. }
  2307. if (language === undefined || badiLocale[language] === undefined) {
  2308. language = 'default';
  2309. }
  2310. return formatItemFallback(language, 'holyDay', this._holyDay);
  2311. }
  2312. valueOf() {
  2313. return this._dayOfYear([this.year, this.month, this.day]) + this._leapYearsBefore() + (this.year - 1) * 365;
  2314. }
  2315. equals(other) {
  2316. return this.isValid && other.isValid && this.valueOf() === other.valueOf();
  2317. }
  2318. get isValid() {
  2319. return this._valid;
  2320. }
  2321. get invalidReason() {
  2322. return this._invalidReason;
  2323. }
  2324. get day() {
  2325. return this._day;
  2326. }
  2327. get month() {
  2328. return this._month;
  2329. }
  2330. get year() {
  2331. return this._year;
  2332. }
  2333. // number of the Badí' weekday between 1 (Jalál ~> Saturday) and 7 (Istiqlál ~> Friday).
  2334. get weekday() {
  2335. return (this._gregorianDate.weekday + 1) % 7 + 1;
  2336. }
  2337. get yearInVahid() {
  2338. return (this._year - 1) % 19 + 1;
  2339. }
  2340. get vahid() {
  2341. return (Math.floor((this._year - 1) / 19) % 19) + 1;
  2342. }
  2343. get kullIShay() {
  2344. return Math.floor((this._year - 1) / 361) + 1;
  2345. }
  2346. // Gregorian date on whose sunset the Badí' date ends.
  2347. get gregorianDate() {
  2348. return this._gregorianDate;
  2349. }
  2350. get ayyamiHaLength() {
  2351. return this._ayyamiHaLength;
  2352. }
  2353. get holyDayNumber() {
  2354. return this._holyDay ? this._holyDay : undefined;
  2355. }
  2356. get workSuspended() {
  2357. return this._holyDay ? this.holyDayNumber < 10 : undefined;
  2358. }
  2359. get nextMonth() {
  2360. let { year, month } = this;
  2361. switch (month) {
  2362. case 18:
  2363. month = 20;
  2364. break;
  2365. case 19:
  2366. month = 1;
  2367. year += 1;
  2368. break;
  2369. case 20:
  2370. month = 19;
  2371. break;
  2372. default:
  2373. month += 1;
  2374. }
  2375. return new BadiDate({ year, month, day: 1 });
  2376. }
  2377. get previousMonth() {
  2378. let { year, month } = this;
  2379. switch (month) {
  2380. case 1:
  2381. month = 19;
  2382. year -= 1;
  2383. break;
  2384. case 19:
  2385. month = 20;
  2386. break;
  2387. case 20:
  2388. month = 18;
  2389. break;
  2390. default:
  2391. month -= 1;
  2392. }
  2393. return new BadiDate({ year, month, day: 1 });
  2394. }
  2395. get nextDay() {
  2396. if (this._day === 19 || (this._month === 20 && this._day === this._ayyamiHaLength)) {
  2397. return this.nextMonth;
  2398. }
  2399. return new BadiDate({ year: this._year, month: this._month, day: this._day + 1 });
  2400. }
  2401. get previousDay() {
  2402. if (this._day === 1) {
  2403. const { previousMonth } = this;
  2404. let day = 19;
  2405. if (this._month === 19) {
  2406. day = this._ayyamiHaLength;
  2407. }
  2408. return new BadiDate({
  2409. year: previousMonth.year,
  2410. month: previousMonth.month,
  2411. day,
  2412. });
  2413. }
  2414. return new BadiDate({ year: this._year, month: this._month, day: this._day - 1 });
  2415. }
  2416. }
  2417. const badiDateSettings = (settings) => {
  2418. if (settings.defaultLanguage) {
  2419. setDefaultLanguage(settings.defaultLanguage);
  2420. }
  2421. if (settings.underlineFormat) {
  2422. setUnderlineFormat(settings.underlineFormat);
  2423. }
  2424. };
  2425. /* eslint-disable max-len, complexity */
  2426. const clockLocations = {
  2427. Canada: [[[-63.29333, 60], [-138.9386, 60], [-139.1889, 60.08888], [-139.0681, 60.35222], [-139.6767, 60.34055], [-139.9794, 60.18777], [-140.45081, 60.30972], [-140.52139, 60.22221], [-140.9955, 60.30721], [-140.99686, 61.8948], [-141.00005, 65.84028], [-141.00206, 68.42821], [-141.00296, 69.58786], [-141.00477, 69.58884], [-140.99813, 70.12335], [-124.80692, 77.04204], [-117.95462, 78.95431], [-99.46935, 82.3539], [-75.0348, 84.79736], [-59.3117, 83.84122], [-60.98493, 82.07503], [-69.57686, 80.21588], [-71.1173, 79.6183], [-74.13178, 79.24647], [-73.93259, 78.5692], [-75.69878, 77.78571], [-77.43842, 77.49355], [-77.55793, 76.52414], [-78.54063, 76.17887], [-79.31085, 74.25332], [-75.79174, 73.25735], [-73.13581, 72.0489], [-69.1652, 71.09276], [-66.31007, 69.91087], [-66.05776, 68.70243], [-60.73262, 66.89639], [-62.3129, 65.07708], [-63.60102, 64.69197], [-64.19861, 60.84087], [-63.29333, 60.00012]]],
  2428. Finland: [[[31.5848296, 62.9070356], [31.4390606, 62.785375], [31.3454013, 62.64032620000001], [31.2218346, 62.49829550000001], [31.138311, 62.4420838], [30.720412, 62.20890580000002], [30.6564061, 62.2085877], [30.602068, 62.14134890000001], [30.4231749, 62.02237140000001], [30.3061104, 61.964546], [30.1556605, 61.8579888], [30.0752371, 61.8183646], [30.0387281, 61.76500110000001], [29.8185491, 61.6549278], [29.74029919999999, 61.5737044], [29.5030724, 61.461338900000015], [29.3304371, 61.3526198], [29.2330501, 61.268169], [29.0298879, 61.191815300000016], [28.9583837, 61.1514492], [28.818984, 61.1216471], [28.7136921, 61.0443349], [28.6578963, 60.95109439999999], [28.5246697, 60.9571371], [28.1354613, 60.7408695], [27.873414, 60.604559], [27.7736111, 60.53333330000002], [27.725, 60.3913889], [27.4550934, 60.223534], [27.2938862, 60.2003975], [26.8756332, 60.200342100000015], [26.6110136, 60.161753200000014], [26.2947105, 60.0465237], [26.0173046, 59.97679690000001], [25.1693516, 59.9434386], [24.2815873, 59.79155570000002], [23.4566746, 59.67247360000001], [22.9224144, 59.6384411], [22.6345729, 59.6079549], [22.3965563, 59.5130947], [21.4475658, 59.4772985], [20.7608658, 59.5324815], [20.3839584, 59.4576178], [20.2843364, 59.4660819], [19.083209799999988, 60.19169020000001], [19.2202109, 60.61151010000001], [20.0251664, 60.72755450000001], [20.7714495, 61.12690790000001], [20.903203, 61.6462488], [20.1658123, 63.1648577], [20.4010006, 63.3318822], [20.8175143, 63.5011379], [21.4628083, 63.6552312], [21.8845783, 63.70121190000001], [22.9611467, 64.2200974], [23.835799, 64.66547409999997], [24.1545056, 65.29247769999998], [24.131900100000014, 65.5153846], [24.1776819, 65.6603564], [24.1318042, 65.7716089], [24.152978, 65.862572], [24.0536762, 65.95152940000006], [24.0491701, 65.99502970000003], [23.9394784, 66.07568309999998], [23.9170552, 66.16186640000002], [23.7313763, 66.19408560000002], [23.6489848, 66.30377249999997], [23.6880374, 66.3815611], [23.650965700000015, 66.4557476], [23.8605347, 66.5595503], [23.86853209999999, 66.6568254], [23.9078441, 66.72140390000003], [23.880337, 66.76350940000003], [23.99566289999999, 66.822049], [23.8525565, 66.9573479], [23.677678, 67.0620298], [23.5545444, 67.16789390000002], [23.596079, 67.20820560000003], [23.5637833, 67.2606725], [23.7311639, 67.28763560000003], [23.7172209, 67.38530669999997], [23.7639366, 67.42772120000002], [23.408239899999984, 67.46939490000003], [23.4059159, 67.50091320000003], [23.5452477, 67.5838871], [23.492249099999984, 67.6652745], [23.47871239999999, 67.8419848], [23.5171915, 67.88433529999998], [23.6407972, 67.9151784], [23.6525654, 67.9589433], [23.3937061, 68.0452571], [23.3077618, 68.14837649999997], [23.1656349, 68.13315060000002], [23.152641, 68.2333806], [23.0702517, 68.29970360000003], [22.9181313, 68.3335115], [22.8028778, 68.39328420000002], [22.3437523, 68.45688960000003], [22.2960914, 68.4840408], [22.045040799999988, 68.479329], [21.8898693, 68.5844051], [21.7010887, 68.59686950000003], [21.6061629, 68.6678769], [21.4298688, 68.691352], [21.39042, 68.76478960000003], [20.9988391, 68.89612380000003], [20.8441913, 68.93656440000004], [20.9116456, 68.96882420000003], [20.775042799999987, 69.0326073], [20.5523258, 69.0600767], [20.7173208, 69.1197912], [21.057543, 69.03628970000003], [21.1086742, 69.1039291], [20.9875741, 69.19192740000003], [21.0961691, 69.260912], [21.2788202, 69.3118841], [21.6270859, 69.27658829999997], [22.1757622, 68.95632440000003], [22.1918678, 68.9187737], [22.3407806, 68.82722570000003], [22.3745217, 68.71666660000004], [22.5353893, 68.74451260000004], [22.800824, 68.68754809999997], [23.0459522, 68.6893436], [23.1675822, 68.6285189], [23.4406356, 68.6921635], [23.6735202, 68.70552140000002], [23.7753915, 68.81885129999998], [23.983330799999987, 68.82714340000003], [24.0755916, 68.7799668], [24.30226, 68.71735020000003], [24.6083879, 68.6819016], [24.9170187, 68.60529109999997], [25.1193208, 68.6428308], [25.1212144, 68.7458351], [25.1573697, 68.80006390000003], [25.2931271, 68.8600372], [25.47250939999999, 68.90329120000003], [25.6543285, 68.90577049999997], [25.745596499999987, 69.03984729999998], [25.742717799999987, 69.14430209999998], [25.6939225, 69.1957144], [25.7410164, 69.31839509999998], [25.8462009, 69.3929115], [25.8084981, 69.4259367], [25.8768225, 69.5261298], [25.9760403, 69.610225], [25.8925512, 69.66539549999997], [26.0071395, 69.7228555], [26.1255598, 69.7345401], [26.3835888, 69.8541585], [26.4653759, 69.93980490000003], [26.6834067, 69.96301920000003], [26.8407548, 69.9603025], [27.0316081, 69.9107924], [27.3049484, 69.95762760000004], [27.43070959999999, 70.0194461], [27.5206048, 70.02243659999996], [27.614207, 70.074151], [27.9593778, 70.0921111], [27.9842853, 70.0139707], [28.160713, 69.92099370000003], [28.3452694, 69.88083179999997], [28.4042254, 69.818425], [29.1339095, 69.69534039999996], [29.1705369, 69.6390414], [29.3364956, 69.47832269999998], [29.2193395, 69.39763620000002], [28.831539, 69.2243617], [28.80543, 69.1111558], [28.929451, 69.0519407], [28.4953735, 68.9300403], [28.468076, 68.8855137], [28.66118, 68.8864737], [28.8014499, 68.8693665], [28.7072131, 68.732555], [28.4341202, 68.53979460000002], [28.6478382, 68.19591340000002], [29.3271337, 68.0745162], [29.6593888, 67.80297219999996], [30.0173409, 67.67356889999996], [29.9305102, 67.5228214], [29.8567823, 67.48926540000004], [29.6361151, 67.332861], [29.522709499999987, 67.3099172], [29.48660609999999, 67.26011490000003], [29.0732544, 66.99615390000004], [29.0331239, 66.92547219999996], [29.0607529, 66.85269279999997], [29.3507185, 66.6439171], [29.4726751, 66.5434478], [29.6969469, 66.277347], [29.9239353, 66.1262486], [29.997268, 65.97889249999997], [30.0647878, 65.90105890000002], [30.138463, 65.66868749999998], [30.0170916, 65.6965272], [29.722432799999986, 65.637045], [29.8637508, 65.5604702], [29.7331208, 65.472637], [29.7467636, 65.347391], [29.6018471, 65.2599435], [29.893525, 65.19295509999998], [29.8193446, 65.1444587], [29.896916, 65.1051579], [29.7328054, 65.09129760000003], [29.6255535, 65.06020520000003], [29.5993537, 64.99509809999998], [29.6470353, 64.8674467], [29.739663, 64.7897553], [30.0430007, 64.7928625], [30.0416232, 64.74110840000003], [30.1365729, 64.6488835], [29.9894058, 64.58761530000002], [29.9869609, 64.5338998], [30.0583348, 64.4508749], [30.0448933, 64.4020122], [30.482439699999983, 64.2623385], [30.466399899999985, 64.2044319], [30.5534271, 64.1322443], [30.5280169, 64.0488769], [30.320039, 63.9082685], [30.260416, 63.82200320000001], [29.9718903, 63.7571676], [30.24571609999999, 63.60696830000001], [30.385620199999988, 63.54577980000001], [30.4841978, 63.4670887], [30.789711, 63.4050884], [30.9330443, 63.3559208], [30.9798739, 63.3078177], [31.1483116, 63.26151890000002], [31.2416464, 63.2166421], [31.2658547, 63.1154671], [31.46252279999998, 63.02421930000001], [31.5848296, 62.9070356]]],
  2429. // Greenland: [[[-57.44887, 82.28507], [-60.15022, 82.05782], [-61.87928, 81.82771], [-62.2191, 81.7294], [-63.42448, 81.28486], [-65.32658, 80.98138], [-66.57577, 80.83605], [-67.38791, 80.54753], [-67.66468, 80.1436], [-68.73755, 79.10919], [-72.47765, 78.62618], [-72.96065, 78.36972], [-73.1359, 78.13036], [-72.78968, 77.34387], [-73.38382, 76.66424], [-72.79822, 76.5702], [-69.80615, 76.29664], [-68.45971, 75.97179], [-66.32252, 75.80508], [-64.89914, 75.80081], [-63.13809, 76.04018], [-62.31741, 75.9034], [-60.47087, 75.78371], [-60.19731, 75.62983], [-58.94919, 75.49305], [-58.81241, 74.92883], [-58.38497, 74.89464], [-58.21399, 74.63817], [-57.47879, 74.17654], [-57.15394, 73.47554], [-55.83743, 71.40673], [-55.23901, 70.48346], [-55.10223, 69.40632], [-53.87121, 68.825], [-54.21316, 66.80748], [-53.75152, 65.52517], [-52.5034, 63.43926], [-47.39122, 59.6265], [-42.68939, 59.38714], [-41.16771, 61.50723], [-30.05428, 67.67946], [-26.83993, 68.124], [-21.04386, 70.27829], [-21.24903, 72.74034], [-16.78656, 74.91174], [-16.39331, 77.2541], [-17.64144, 78.51933], [-16.82075, 79.78455], [-11.02468, 81.34043], [-11.93085, 82.02433], [-19.48798, 82.45177], [-19.71024, 83.01599], [-27.19898, 83.85377], [-39.64602, 83.80248], [-50.82784, 82.9476], [-57.44887, 82.28507]]],
  2430. Iceland: [[[-25.0, 63.0], [-12.8, 63.0], [-12.8, 66.8], [-25.0, 66.8]]],
  2431. Norway: [[[30.79367, 69.78758], [30.89032, 69.73729], [30.95448, 69.63243], [30.93257, 69.55989], [30.81756, 69.52877], [30.51593, 69.54042], [30.41768, 69.58992], [30.23373, 69.65016], [30.13777, 69.64353], [30.18838, 69.56846], [30.12305, 69.51749], [30.11721, 69.46989], [30.00876, 69.41591], [29.85802, 69.42374], [29.7244, 69.38965], [29.56938, 69.31756], [29.39594, 69.32384], [29.28845, 69.29618], [29.31313, 69.23752], [29.24224, 69.11306], [29.05666, 69.01528], [28.85456, 69.07664], [28.80541, 69.11116], [28.83152, 69.22436], [29.21932, 69.39764], [29.33647, 69.47832], [29.17052, 69.63904], [29.13389, 69.69534], [28.40421, 69.81842], [28.33046, 69.84919], [28.34506, 69.8808], [28.1607, 69.92099], [27.98428, 70.01397], [27.94828, 70.09187], [27.79768, 70.07731], [27.61245, 70.07456], [27.52598, 70.02346], [27.42855, 70.01921], [27.27471, 69.97591], [27.29177, 69.95225], [27.03749, 69.91039], [26.89776, 69.93245], [26.85129, 69.96013], [26.71807, 69.94499], [26.67869, 69.96477], [26.46435, 69.93939], [26.38594, 69.85535], [26.24129, 69.81453], [26.13562, 69.73861], [26.01418, 69.72334], [25.89149, 69.6655], [25.97672, 69.61067], [25.93749, 69.57253], [25.83994, 69.54298], [25.87704, 69.5222], [25.80934, 69.42639], [25.8461, 69.39325], [25.75938, 69.34038], [25.74753, 69.28679], [25.70204, 69.25366], [25.69302, 69.19674], [25.74351, 69.13879], [25.72429, 69.0796], [25.77744, 69.01828], [25.71241, 68.98063], [25.65423, 68.90587], [25.60033, 68.88487], [25.48119, 68.90507], [25.2677, 68.85099], [25.15713, 68.79989], [25.11152, 68.70252], [25.11924, 68.6428], [24.91692, 68.60525], [24.85717, 68.56221], [24.78342, 68.63623], [24.60839, 68.6819], [24.30226, 68.71735], [24.07559, 68.77997], [23.98333, 68.82714], [23.87146, 68.83652], [23.77539, 68.81885], [23.73106, 68.75075], [23.67352, 68.70552], [23.44064, 68.69216], [23.16758, 68.62852], [23.04595, 68.68934], [22.80082, 68.68755], [22.53539, 68.74451], [22.37452, 68.71667], [22.34078, 68.82723], [22.19187, 68.91877], [22.17576, 68.95632], [21.98361, 69.07289], [21.8464, 69.14416], [21.62709, 69.27659], [21.27882, 69.31188], [21.09617, 69.26091], [21.00331, 69.22234], [20.98758, 69.19193], [21.05563, 69.12209], [21.10868, 69.10393], [21.05754, 69.03629], [20.71732, 69.11979], [20.55233, 69.06008], [20.06005, 69.04576], [20.30659, 68.92618], [20.33587, 68.80231], [20.20284, 68.66592], [20.05225, 68.59107], [19.9375, 68.55794], [20.02589, 68.53081], [20.22654, 68.49081], [19.97796, 68.38816], [19.9214, 68.35601], [18.9838, 68.51696], [18.62122, 68.50696], [18.40569, 68.58188], [18.12592, 68.53652], [18.10109, 68.40605], [18.15135, 68.19879], [17.89976, 67.96937], [17.66475, 68.03838], [17.28152, 68.11881], [17.18051, 68.05046], [16.73812, 67.91421], [16.55628, 67.64719], [16.40757, 67.53403], [16.158, 67.51916], [16.08983, 67.43528], [16.4041, 67.20497], [16.38776, 67.04546], [16.19402, 66.98259], [16.03876, 66.91245], [15.99364, 66.87323], [15.62137, 66.59434], [15.37723, 66.4843], [15.48473, 66.28246], [15.03568, 66.15356], [14.51629, 66.13258], [14.58441, 65.90134], [14.62548, 65.81181], [14.54147, 65.70075], [14.49877, 65.5213], [14.50683, 65.30973], [14.3788, 65.24762], [14.32598, 65.11892], [14.12989, 64.97856], [13.70547, 64.63996], [13.65426, 64.58034], [13.89118, 64.50713], [14.08523, 64.47825], [14.11387, 64.46248], [14.15711, 64.19505], [13.96752, 64.00797], [13.7154, 64.04629], [13.21111, 64.09537], [12.92672, 64.05795], [12.68356, 63.97422], [12.48023, 63.81876], [12.33057, 63.71507], [12.29946, 63.67198], [12.14977, 63.59395], [12.21288, 63.47859], [12.08407, 63.35558], [11.97458, 63.26923], [12.21823, 63.00033], [12.07469, 62.90254], [12.13638, 62.74792], [12.05614, 62.61192], [12.29937, 62.26749], [12.13766, 61.72382], [12.41961, 61.56298], [12.56932, 61.56875], [12.87085, 61.3565], [12.83383, 61.25846], [12.79035, 61.19705], [12.70703, 61.14327], [12.68258, 61.06122], [12.61251, 61.04683], [12.44761, 61.05073], [12.22399, 61.01308], [12.33279, 60.89017], [12.33448, 60.85236], [12.39537, 60.73389], [12.51102, 60.64246], [12.51578, 60.60015], [12.60688, 60.51274], [12.60605, 60.40593], [12.49879, 60.32365], [12.54191, 60.19338], [12.50064, 60.09908], [12.44856, 60.03917], [12.34114, 59.96567], [12.23104, 59.92759], [12.17429, 59.88981], [12.05346, 59.88594], [11.98518, 59.90072], [11.84045, 59.84174], [11.92597, 59.794], [11.93988, 59.69458], [11.88922, 59.69321], [11.85571, 59.64829], [11.72056, 59.62549], [11.69113, 59.58955], [11.75993, 59.45818], [11.77987, 59.38646], [11.81625, 59.34474], [11.82979, 59.24223], [11.78393, 59.20838], [11.77539, 59.08659], [11.71051, 59.03368], [11.68908, 58.95685], [11.59063, 58.89072], [11.45623, 58.89021], [11.45853, 58.99597], [11.34184, 59.12041], [11.20498, 59.08311], [11.17718, 59.09736], [11.1, 59], [11.0203, 58.97], [9.67858, 58.87844], [8.51901, 58.15871], [7.92368, 57.95878], [6.62638, 57.9188], [5.34686, 58.63409], [4.70265, 59.35382], [4.57381, 61.1576], [4.78262, 62.0506], [5.46681, 62.55263], [6.79965, 62.99691], [8.29243, 63.77884], [9.92293, 64.11205], [10.71819, 65.0095], [11.4246, 65.12057], [11.79779, 65.84919], [11.95329, 67.64852], [13.20171, 68.29717], [14.5701, 68.89694], [16.08064, 69.41675], [17.91552, 69.8166], [19.1906, 70.36306], [19.81259, 70.33196], [20.19467, 70.19424], [21.78519, 70.50523], [21.89626, 70.73182], [23.70892, 70.96284], [23.91773, 71.1139], [24.46864, 71.07391], [24.71744, 71.21608], [25.89478, 71.26051], [26.77445, 71.08724], [27.79185, 71.22052], [28.65819, 71.06503], [30.03102, 70.78069], [31.23946, 70.43859], [31.19482, 70.34084], [30.79367, 69.78758]], [[4.2, 80.84], [-11.5, 70.1], [19.2, 73.5], [39.2, 81.4]]],
  2432. Sweden: [[[15.4538561, 66.34534869999999], [15.3772302, 66.4843117], [15.625833, 66.605833], [15.80794, 66.735271], [16.0387632, 66.9124213], [16.195223, 66.982232], [16.3877, 67.0455], [16.4040109, 67.2049795], [16.09015, 67.435232], [16.1566, 67.519458], [16.407797, 67.533978], [16.555733, 67.647289], [16.7381292, 67.91418620000002], [17.180003, 68.050508], [17.2818957, 68.1188101], [17.6648128, 68.0384733], [17.8998048, 67.9693359], [18.1514126, 68.198755], [18.1010915, 68.406043], [18.1258499, 68.5364954], [18.4056102, 68.5818554], [18.6211478, 68.5069382], [18.9836971, 68.5169473], [19.921397, 68.3560137], [19.9778586, 68.3881535], [20.2264196, 68.4908071], [19.9375039, 68.5579418], [20.0521233, 68.5910515], [20.2027029, 68.6659076], [20.3358646, 68.8023404], [20.3064282, 68.9261735], [20.0600472, 69.0457578], [20.5486422, 69.05996990000001], [20.7750428, 69.0326073], [20.9137291, 68.9603927], [20.8441913, 68.93656440000002], [20.9156942, 68.8971424], [20.9967921, 68.896741], [21.2340165, 68.8140862], [21.3194271, 68.7592708], [21.3893348, 68.76495460000002], [21.4298688, 68.691352], [21.5651505, 68.6752534], [21.7013706, 68.6305605], [21.7016655, 68.5963461], [21.8898693, 68.5844051], [21.9919125, 68.5339794], [22.0182391, 68.495951], [22.1528153, 68.4701805], [22.2945732, 68.4838241], [22.4661749, 68.4413001], [22.6482126, 68.41604160000001], [22.7362404, 68.3852018], [22.8041064, 68.39294], [22.9181313, 68.3335115], [23.0702517, 68.29970360000002], [23.1528179, 68.2310713], [23.1415318, 68.1543005], [23.2783645, 68.15733889999998], [23.3216014, 68.1347101], [23.3966203, 68.044179], [23.5310194, 68.0067455], [23.6632301, 67.94218640000001], [23.6407972, 67.9151784], [23.5098377, 67.87994509999999], [23.4739757, 67.81714420000002], [23.4946531, 67.7903019], [23.493057, 67.6641861], [23.5588847, 67.6192741], [23.5450496, 67.5829545], [23.4081036, 67.50173829999999], [23.4104738, 67.46759370000002], [23.5365192, 67.4599963], [23.7632859, 67.4262029], [23.7179667, 67.384843], [23.7750768, 67.3393805], [23.7311639, 67.28763560000002], [23.5834506, 67.269308], [23.5535126, 67.2468025], [23.5958386, 67.2071971], [23.5569385, 67.16578719999998], [23.6536532, 67.1042345], [23.6739708, 67.0650834], [23.8564714, 66.9558968], [23.8640579, 66.9221303], [23.9330592, 66.8845665], [23.9945079, 66.82348849999998], [23.9782068, 66.78409040000001], [23.8797209, 66.7620511], [23.9078441, 66.72140390000001], [23.8685321, 66.6568254], [23.8846737, 66.61277119999998], [23.8605347, 66.5595503], [23.7853219, 66.5333886], [23.6509657, 66.4557476], [23.6880374, 66.3815611], [23.6489848, 66.3037725], [23.7263744, 66.1968556], [23.9159179, 66.1621612], [23.936749, 66.0794759], [24.0374327, 66.0090364], [24.0421963, 65.9633925], [24.152978, 65.862572], [24.1318042, 65.7716089], [24.1721721, 65.72528229999999], [24.1776819, 65.6603564], [24.1319001, 65.5153846], [24.1444599, 65.3956667], [23.1299456, 65.2854532], [21.8250561, 64.8363612], [22.0872366, 64.43431070000001], [21.5096176, 64.04121570000002], [21.4570471, 63.7528427], [20.20662871333013, 63.274568586669865], [19.4322896, 63.0737152], [18.2961641, 62.4173632], [17.7755886, 61.1718712], [17.8981165, 60.9377595], [17.7095869, 60.7102649], [17.3865202, 60.6893467], [17.3489744, 60.5862714], [17.3024177, 60.508762], [17.29774, 60.4647038], [17.2565412, 60.4243351], [17.1955585, 60.4105852], [17.1986283, 60.3077815], [17.0585097, 60.2727725], [16.908878, 60.281498], [16.9048859, 60.2394077], [16.7046001, 60.1950497], [16.6294785, 60.2384924], [16.6154023, 60.2786235], [16.5166127, 60.3554293], [16.3927146, 60.3794045], [16.2589904, 60.4931441], [16.1947891, 60.5354328], [16.13651, 60.6103267], [16.2382972, 60.6230491], [16.3769218, 60.7434488], [16.386117, 60.7868], [16.2552139, 60.8636119], [16.1310092, 60.9920575], [15.9216155, 61.00763], [15.7619207, 61.0496869], [15.6803816, 61.11321], [15.6573361, 61.2154788], [15.4760187, 61.3149858], [15.3370007, 61.4016369], [15.20475, 61.503826], [15.1531933, 61.5956892], [14.8564014, 61.7835491], [14.7971, 61.798451], [14.6666465, 61.8918775], [14.5296202, 61.783626], [14.4997464, 61.62599], [14.3947754, 61.5637652], [14.3364964, 61.59913920000001], [14.1822587, 61.6175455], [13.9769516, 61.6213397], [13.8902353, 61.6525473], [13.6131488, 61.6726273], [13.564749, 61.656455], [13.5066718, 61.6929666], [13.5145384, 61.7377738], [13.4160916, 61.8280592], [13.2092287, 61.9365972], [13.0799221, 62.0376119], [13.0423631, 62.0182008], [12.9513736, 62.1334555], [12.9026405, 62.1418727], [12.8059683, 62.2205277], [12.6078489, 62.214806], [12.299389, 62.2659814], [12.056144, 62.6119191], [12.1363845, 62.7479169], [12.074689, 62.9025463], [12.218233, 63.0003345], [11.9745822, 63.2692252], [12.0840901, 63.3555796], [12.2128783, 63.4785906], [12.1497625, 63.593946], [12.2975812, 63.6732169], [12.3399662, 63.7269855], [12.4797773, 63.8196667], [12.6860556, 63.9738931], [12.9268369, 64.05783829999999], [13.2109436, 64.0951725], [13.7151219, 64.045304], [13.981667, 64.013056], [14.1579301, 64.1860759], [14.120556, 64.452778], [14.086006, 64.47814109999999], [13.8924406, 64.507004], [13.6540802, 64.579929], [13.7050997, 64.6396655], [14.1081927, 64.96225790000001], [14.3257603, 65.1190618], [14.3790211, 65.24804960000002], [14.5056577, 65.3099238], [14.4967711, 65.5174317], [14.5295213, 65.682227], [14.6240045, 65.81419090000001], [14.584253, 65.9013501], [14.5162846, 66.132567], [15.035653, 66.1535649], [15.4847146, 66.282458], [15.4538561, 66.34534869999999]]],
  2433. USA: [[[-130.01989, 55.9153], [-130.17038, 55.77749], [-130.13861, 55.55335], [-129.99201, 55.28955], [-130.25933, 54.99635], [-130.66666, 54.71444], [-131.17048, 54.72103], [-132.10046, 54.6269], [-132.86477, 54.63066], [-133.60649, 54.72479], [-134.93933, 56.02375], [-136.80681, 57.75192], [-137.09296, 58.25079], [-139.07716, 59.1017], [-141.32115, 59.76436], [-143.47102, 59.81707], [-146.37014, 59.17701], [-149.21654, 59.54598], [-152.0253, 57.0535], [-155.80544, 55.02035], [-159.93198, 54.32757], [-173.1399, 51.33056], [-179.49537, 50.84863], [-179.28453, 52.29443], [-171.78447, 63.95114], [-169.94709, 63.91437], [-169.09903, 65.86662], [-168.1474, 65.7885], [-164.9772, 66.85025], [-167.15342, 68.37135], [-166.29498, 69.12437], [-161.71663, 70.74335], [-156.23466, 71.55661], [-143.75716, 70.6304], [-141.58847, 70.26895], [-141.56335, 69.73575], [-141.39798, 69.64277], [-141.00304, 69.64616], [-141.00189, 60.6745], [-141.00157, 60.30507], [-140.52034, 60.21906], [-140.44797, 60.30796], [-139.97408, 60.18451], [-139.68007, 60.33572], [-139.05208, 60.35373], [-139.17702, 60.08286], [-138.70578, 59.90624], [-138.60921, 59.76], [-137.60744, 59.24348], [-137.45151, 58.90854], [-136.82468, 59.1598], [-136.58199, 59.16554], [-136.19525, 59.63881], [-135.9476, 59.66343], [-135.47958, 59.7981], [-135.02888, 59.56364], [-135.10063, 59.42776], [-134.95978, 59.28104], [-134.7007, 59.2489], [-134.48273, 59.13097], [-134.258, 58.86087], [-133.84105, 58.72985], [-133.37997, 58.43181], [-133.45987, 58.38848], [-133.17195, 58.15383], [-132.55389, 57.4967], [-132.2478, 57.21112], [-132.36871, 57.09167], [-132.0448, 57.0451], [-132.12311, 56.8739], [-131.87311, 56.80627], [-131.83539, 56.59912], [-131.5813, 56.6123], [-131.08698, 56.40613], [-130.7818, 56.36713], [-130.4682, 56.24329], [-130.42548, 56.14172], [-130.10541, 56.12268], [-130.01989, 55.9153]], [[179.9, 52.2], [172.0, 53.3], [172.0, 52.4], [179.9, 51.0]]],
  2434. };
  2435. /* eslint-enable max-len */
  2436. let usingClockLocations = true;
  2437. const useClockLocations = (useClockLocations) => {
  2438. usingClockLocations = useClockLocations;
  2439. };
  2440. const pointInPolygon = (coords, polygon) => {
  2441. const [x, y] = coords;
  2442. let inside = false;
  2443. for (let i = 0, j = polygon.length - 1; i < polygon.length; i++) {
  2444. const [xi, yi] = polygon[i];
  2445. const [xj, yj] = polygon[j];
  2446. // Check that a) the segment crosses the y coordinate of the point
  2447. // b) at least one of the two vertices is left of the point
  2448. // c) at the y coordinate of the point, the segment is left of it
  2449. if ((((yi < y) !== (yj < y)) && (xi <= x || xj <= x)) && ((xi + (y - yi) * (xj - xi) / (yj - yi)) < x)) {
  2450. inside = !inside;
  2451. }
  2452. j = i;
  2453. }
  2454. return inside;
  2455. };
  2456. // The name of a country being returned doesn't just mean that the coordinates are within that country, but that they
  2457. // are within the region of that country where a fixed time rule applies.
  2458. const clockLocationFromPolygons = (latitude, longitude) => {
  2459. if (!usingClockLocations) {
  2460. return undefined;
  2461. }
  2462. // First exclude as large an area as possible from having to check polygons
  2463. if (latitude < 51.0) {
  2464. return undefined;
  2465. }
  2466. if (latitude < 57.0 && longitude > -129.0 && longitude < 172.0) {
  2467. return undefined;
  2468. }
  2469. // Make a list of plausible areas based on longitude, then only check those
  2470. const countries = [];
  2471. const labels = [];
  2472. if (longitude < -129.9 || longitude > 172.4) {
  2473. countries.push(clockLocations.USA);
  2474. labels.push('USA');
  2475. }
  2476. if (longitude > -141.1 && longitude < -61.1) {
  2477. countries.push(clockLocations.Canada);
  2478. labels.push('Canada');
  2479. }
  2480. // Greenland doesn't currently have a rule for this
  2481. // if (longitude > -73.1 && longitude < -11.3) {
  2482. // countries.push(clockLocations.Greenland);
  2483. // labels.push('Greenland');
  2484. // }
  2485. if (longitude > -25.0 && longitude < -12.8) {
  2486. countries.push(clockLocations.Iceland);
  2487. labels.push('Iceland');
  2488. }
  2489. if (longitude > -9.2 && longitude < 33.6) {
  2490. countries.push(clockLocations.Norway);
  2491. labels.push('Norway');
  2492. }
  2493. if (longitude > 10.9 && longitude < 24.2) {
  2494. countries.push(clockLocations.Sweden);
  2495. labels.push('Sweden');
  2496. }
  2497. if (longitude > 19.1 && longitude < 31.6) {
  2498. countries.push(clockLocations.Finland);
  2499. labels.push('Finland');
  2500. }
  2501. // Russia currently doesn't have a rule for this
  2502. // if (longitude > 27.3 || longitude < -169.6) {
  2503. // countries.push(clockLocations.Russia);
  2504. // labels.push('Russia');
  2505. // }
  2506. for (let i = 0; i < countries.length; i++) {
  2507. for (let j = 0; j < countries[i].length; j++) {
  2508. if (pointInPolygon([longitude, latitude], countries[i][j])) {
  2509. return labels[i];
  2510. }
  2511. }
  2512. }
  2513. return undefined;
  2514. };
  2515. /* eslint-disable complexity */
  2516. class LocalBadiDate {
  2517. constructor(date, latitude, longitude, timezoneId) {
  2518. this._latitude = latitude;
  2519. this._longitude = longitude;
  2520. this._timezoneId = timezoneId;
  2521. // If a datetime object is being passed, we use date and time, not just the
  2522. // date. For a JS Date object, we can't assume it's in the correct timezone,
  2523. // so in that case we use the date information only.
  2524. this._badiDate = new BadiDate(this._setInputDateToCorrectDay(date, latitude, longitude));
  2525. const gregDate = this._badiDate.gregorianDate.setZone(timezoneId, { keepLocalTime: true });
  2526. this._clockLocation = clockLocationFromPolygons(latitude, longitude);
  2527. if (!this._clockLocation ||
  2528. (this._clockLocation === 'Finland' &&
  2529. this._badiDate.month === 19)) {
  2530. this._end = sunset(gregDate, latitude, longitude);
  2531. this._solarNoon = solarNoon(gregDate, longitude);
  2532. this._sunrise = sunrise(gregDate, latitude, longitude);
  2533. this._start = sunset(gregDate.minus({ days: 1 }), latitude, longitude);
  2534. }
  2535. else {
  2536. // First we set times to 18:00, 06:00, 12:00, 18:00, modifications are
  2537. // then made depending on the region.
  2538. this._start = gregDate.minus({ days: 1 }).set({ hour: 18 });
  2539. this._solarNoon = gregDate.set({ hour: 12 });
  2540. this._sunrise = gregDate.set({ hour: 6 });
  2541. this._end = gregDate.set({ hour: 18 });
  2542. if (this._clockLocation === 'Canada') {
  2543. this._sunrise = this._sunrise.plus({ minutes: 30 });
  2544. }
  2545. else if (this._clockLocation === 'Iceland') {
  2546. this._solarNoon = this._solarNoon.plus({ hours: 1 });
  2547. }
  2548. else if (this._clockLocation === 'Finland' ||
  2549. this._clockLocation === 'USA') {
  2550. if (this._end.isInDST) {
  2551. this._sunrise = this._sunrise.plus({ hours: 1 });
  2552. this._solarNoon = this._solarNoon.plus({ hours: 1 });
  2553. this._end = this._end.plus({ hours: 1 });
  2554. }
  2555. if (this._start.isInDST) {
  2556. this._start = this._start.plus({ hours: 1 });
  2557. }
  2558. }
  2559. }
  2560. switch (this._badiDate.holyDayNumber) {
  2561. case 2:
  2562. // First Day of Ridvan: 15:00 local standard time
  2563. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 16 : 15 });
  2564. break;
  2565. case 5:
  2566. // Declaration of the Báb: 2 hours 11 minutes after sunset
  2567. this._holyDayCommemoration = this._start.plus({ minutes: 131 });
  2568. break;
  2569. case 6:
  2570. // Ascension of Bahá'u'lláh: 03:00 local standard time
  2571. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 4 : 3 });
  2572. break;
  2573. case 7:
  2574. // Martyrdom of the Báb: solar noon
  2575. this._holyDayCommemoration = this._solarNoon;
  2576. break;
  2577. case 11:
  2578. // Ascension of 'Abdu'l-Bahá: 01:00 local standard time
  2579. this._holyDayCommemoration = gregDate.set({ hour: gregDate.isInDST ? 2 : 1 });
  2580. break;
  2581. // skip default
  2582. }
  2583. }
  2584. _setInputDateToCorrectDay(date, latitude, longitude) {
  2585. if (DateTime.isDateTime(date)) {
  2586. const sunset$1 = sunset(date, latitude, longitude);
  2587. return (date > sunset$1) ? date.plus({ days: 1 }) : date;
  2588. }
  2589. return date;
  2590. }
  2591. get badiDate() {
  2592. return this._badiDate;
  2593. }
  2594. get start() {
  2595. return this._start;
  2596. }
  2597. get sunrise() {
  2598. return this._sunrise;
  2599. }
  2600. get solarNoon() {
  2601. return this._solarNoon;
  2602. }
  2603. get end() {
  2604. return this._end;
  2605. }
  2606. get holyDayCommemoration() {
  2607. return this._holyDayCommemoration;
  2608. }
  2609. get clockLocation() {
  2610. return this._clockLocation;
  2611. }
  2612. get latitude() {
  2613. return this._latitude;
  2614. }
  2615. get longitude() {
  2616. return this._longitude;
  2617. }
  2618. get timezoneId() {
  2619. return this._timezoneId;
  2620. }
  2621. get nextMonth() {
  2622. return new LocalBadiDate(this.badiDate.nextMonth, this._latitude, this._longitude, this._timezoneId);
  2623. }
  2624. get previousMonth() {
  2625. return new LocalBadiDate(this.badiDate.previousMonth, this._latitude, this._longitude, this._timezoneId);
  2626. }
  2627. get nextDay() {
  2628. return new LocalBadiDate(this.badiDate.nextDay, this._latitude, this._longitude, this._timezoneId);
  2629. }
  2630. get previousDay() {
  2631. return new LocalBadiDate(this.badiDate.previousDay, this._latitude, this._longitude, this._timezoneId);
  2632. }
  2633. }
  2634. const badiDateSettings$1 = (settings) => {
  2635. if (typeof settings.defaultLanguage === 'string' ||
  2636. typeof settings.underlineFormat === 'string') {
  2637. badiDateSettings(settings);
  2638. }
  2639. if (typeof settings.useClockLocations === 'boolean') {
  2640. useClockLocations(settings.useClockLocations);
  2641. }
  2642. };
  2643. settings({ returnTimeForNoEventCase: true, roundToNearestMinute: true });
  2644. export { BadiDate, LocalBadiDate, badiDateSettings$1 as badiDateSettings };