Advertisement
Guest User

MithraLib

a guest
Jan 27th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 57.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data;
  5.  
  6. namespace MithraLib
  7. {
  8. public class Log
  9. {
  10. public static void WriteLine(string entry)
  11. {
  12. System.Diagnostics.Debug.WriteLine(entry);
  13. }
  14. }
  15.  
  16. public static class Calendar
  17. {
  18. public static MannicDay Convert(DateTime dt)
  19. {
  20. return Converttosolar(dt, "?");
  21. }
  22.  
  23. public static MannicDay Converttosolar(DateTime dt, string calendar)
  24. {
  25. int day_of_the_year_to_convert = dt.DayOfYear - 1;
  26. int year = dt.Year;
  27. int month = dt.Month;
  28. int day = dt.Day;
  29. if ((year == 1582) && (dt.Month == 10) && (dt.Day > 4) && (dt.Day < 15))
  30. {
  31. calendar = "Gregorian";
  32. }
  33.  
  34. MannicDay[] YearArray = MannicYear(year, calendar);
  35. return YearArray[day_of_the_year_to_convert];
  36. }
  37.  
  38. public static LunisolarDay createLunisolarDay(int year, double month, int day)
  39. {
  40. return createLunisolarDay(year, month, day, 0);
  41. }
  42.  
  43. public static LunisolarDay createLunisolarDay(int year, double month, int day, int hour)
  44. {
  45. return createLunisolarDay(year, month, day, hour, 0);
  46. }
  47.  
  48. public static LunisolarDay createLunisolarDay(int year, double month, int day, int hour, int min)
  49. {
  50. return createLunisolarDay(year, month, day, hour, min, 0);
  51. }
  52.  
  53. public static LunisolarDay createLunisolarDay(int year, double month, int day, int hour, int min, int sec)
  54. {
  55. int mannic_year = year;
  56. int gregorian_year;
  57. if (mannic_year > 10000)
  58. {
  59. gregorian_year = mannic_year - 10000;
  60. }
  61. else
  62. {
  63. gregorian_year = mannic_year - 10001;
  64. }
  65. LunisolarYear Calendar_Year = createLunisolarYear(gregorian_year, "Gregorian");
  66. int i = 0;
  67. bool found = false;
  68. LunisolarDay created_day = Calendar_Year.DaysArray[i];
  69. double checkmonth;
  70. int checkday;
  71. while(found == false)
  72. {
  73. created_day = Calendar_Year.DaysArray[i];
  74. checkmonth = created_day.month;
  75. checkday = created_day.day;
  76. if((checkday == day) && (checkmonth == month))
  77. {
  78. found = true;
  79. }
  80. else
  81. {
  82. i++;
  83. }
  84. }
  85. DateTime dt = created_day.Gregorian;
  86. int gregmonth = dt.Month;
  87. int gregday = dt.Day;
  88. DateTime gregdate = new DateTime(gregorian_year, gregmonth, gregday, hour, min, sec);
  89. created_day.Gregorian = gregdate;
  90. return created_day;
  91. }
  92.  
  93. public static LunisolarDay ConverttoLunisolar(DateTime dt)
  94. {
  95. return ConverttoLunisolar(dt, "?");
  96. }
  97.  
  98. public static LunisolarDay ConverttoLunisolar(DateTime dt, string calendar)
  99. {
  100. int day_of_the_year_to_convert = dt.DayOfYear - 1;
  101. int year = dt.Year;
  102. int month = dt.Month;
  103. int day = dt.Day;
  104. if ((year == 1582) && (dt.Month == 10) && (dt.Day > 4) && (dt.Day < 15))
  105. {
  106. calendar = "Gregorian";
  107. }
  108.  
  109. //MannicDay[] YearArray = MannicYear(year, calendar);
  110. //return YearArray[day_of_the_year_to_convert];
  111. LunisolarYear converted_year = createLunisolarYear(year, calendar);
  112. LunisolarDay converted_day = converted_year.DaysArray[day_of_the_year_to_convert];
  113. return converted_day;
  114. }
  115.  
  116. public static LunisolarYear createLunisolarYear(int gregyear)
  117. {
  118. return createLunisolarYear(gregyear, "gregorian");
  119. }
  120.  
  121. public static LunisolarYear createLunisolarYear(int gregyear, string calendar)
  122. {
  123. DateTime[] FourPoints = Points(gregyear, calendar);
  124. int i = 0;
  125. //int j = 0;
  126. int m = 1;
  127. DateTime[] months = Moons(gregyear);
  128. ////Console.WriteLine("New Moons");
  129. //Object[,] DaysList = new Object[19,4];
  130. //LunisolarArrayElement[] DaysList = new LunisolarArrayElement[17];
  131. List<LunisolarArrayElement> DaysList = new List<LunisolarArrayElement>();
  132. ////Console.WriteLine("Four Points");
  133.  
  134. string info = "0";
  135. foreach (DateTime element in FourPoints)
  136. {
  137. //count++;
  138. ////Console.WriteLine(element);
  139. switch (i)
  140. {
  141. case 0:
  142. info = "Vernal";
  143. break;
  144. case 1:
  145. info = "Midsummer";
  146. break;
  147. case 2:
  148. info = "Mabon";
  149. break;
  150. case 3:
  151. info = "Yule";
  152. break;
  153. }
  154. DaysList.Add(new LunisolarArrayElement(element, info, 0));
  155. //DaysList[i] = new LunisolarArrayElement(element, info, 0);
  156. //DaysList[i, 0] = element.DayOfYear;
  157. //DaysList[i, 1] = element;
  158. //DaysList[i, 2] = info;
  159. //DaysList[i, 3] = true;
  160. i++;
  161. }
  162. ////Console.WriteLine("months");
  163. foreach (DateTime element in months)
  164. {
  165. //count++;
  166. ////Console.WriteLine(element);
  167. //DaysList[i, 0] = element.DayOfYear;
  168. //DaysList[i, 1] = element;
  169. //DaysList[i, 2] = "New Moon " + m;
  170. //DaysList[i, 3] = false;
  171. info = "moon";
  172. DaysList.Add(new LunisolarArrayElement(element, info, m));
  173. m++;
  174. i++;
  175. }
  176. DateTime dt = new DateTime(gregyear, 1, 1, 0, 0, 0);
  177. DateTime newyear = dt;
  178. //somehow make the four points of the year, as well as the year boundary round so that they are month boundaries
  179. DateTime new_year_eve = new DateTime(gregyear, 12, 31, 0, 0, 0);
  180. int yeardays = new_year_eve.DayOfYear;
  181.  
  182. //Sort array DaysList by element.dayoftheyear
  183.  
  184.  
  185. int manuyear = gregyear;
  186. if (manuyear > 0)
  187. {
  188. manuyear += 10000;
  189. }
  190. else
  191. {
  192. manuyear += 10001;
  193. }
  194.  
  195. foreach (var item in DaysList)
  196. {
  197. //Console.WriteLine(item);
  198.  
  199. }
  200.  
  201. //Console.WriteLine(" xxxxxxxxxxxxx ");
  202.  
  203. //List<LunisolarArrayElement>.Sort(DaysList);
  204. DaysList.Sort();
  205.  
  206. foreach (var item in DaysList)
  207. {
  208. //Console.WriteLine(item);
  209.  
  210. }
  211.  
  212. //Console.WriteLine(" xxxxxxxxxxxxx ");
  213.  
  214.  
  215. bool complete = false;
  216. i = 0;
  217. LunisolarArrayElement[] QuarterArray = new LunisolarArrayElement[4];
  218. int q = 0;
  219. bool isquarter;
  220. int quarter = 4;
  221. int enditem = DaysList.Count - 1;
  222. LunisolarArrayElement LastItem = DaysList[enditem];
  223. if (LastItem.info == "Yule")
  224. {
  225. quarter = 3;
  226. DaysList[enditem - 1].info = "Yule";
  227. DaysList[enditem - 1].number = 0;
  228. DaysList.RemoveAt(enditem);
  229. }
  230. while (complete == false)
  231. {
  232. isquarter = DaysList[i].isquarter();
  233. //check last item, if it is Yule then fix it and set quarter to 3
  234.  
  235. if (isquarter == true)
  236. {
  237. LunisolarArrayElement Fudge = LunisolarFudge(DaysList[i - 1].getdate(), DaysList[i].getdate(), DaysList[i + 1].getdate());
  238. DaysList[i].date = Fudge.date;
  239. int change = (int)(i + Fudge.number);
  240. //DaysList[change] = new LunisolarArrayElement(new DateTime(1, 1, 1, 0, 0, 0), "0", 999);
  241. DaysList.RemoveAt(change);
  242. q++;
  243. }
  244. //Console.WriteLine(DaysList[i]);
  245. i++;
  246.  
  247. if ((i == DaysList.Count - 1) || (q == quarter))
  248. {
  249. complete = true;
  250. }
  251. }
  252.  
  253. DaysList.Add(new LunisolarArrayElement(new DateTime(1, 12, 31, 0, 0, 0), "end", 999));
  254. DaysList.Add(new LunisolarArrayElement(new DateTime(1, 12, 31, 0, 0, 0), "end", 999));
  255. DaysList.Add(new LunisolarArrayElement(new DateTime(1, 12, 31, 0, 0, 0), "end", 999));
  256. DaysList.Add(new LunisolarArrayElement(new DateTime(1, 12, 31, 0, 0, 0), "end", 999));
  257.  
  258. //Array.Sort(DaysList);
  259. DaysList.Sort();
  260.  
  261.  
  262.  
  263.  
  264.  
  265. foreach (var item in DaysList)
  266. {
  267. //Console.WriteLine(item);
  268. }
  269.  
  270.  
  271.  
  272. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  273. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  274.  
  275. //DaysList.Insert(0, DaysList[10]);
  276.  
  277. Dictionary<double, int> monthlengths = new Dictionary<double, int>();
  278. double month = 1;
  279. monthlengths.Add(1, 0);
  280. monthlengths.Add(2, 0);
  281. monthlengths.Add(3, 0);
  282. monthlengths.Add(3.5, 0);
  283. monthlengths.Add(4, 0);
  284. monthlengths.Add(5, 0);
  285. monthlengths.Add(6, 0);
  286. monthlengths.Add(6.5, 0);
  287. monthlengths.Add(7, 0);
  288. monthlengths.Add(8, 0);
  289. monthlengths.Add(9, 0);
  290. monthlengths.Add(9.5, 0);
  291. monthlengths.Add(10, 0);
  292. monthlengths.Add(11, 0);
  293. monthlengths.Add(12, 0);
  294. monthlengths.Add(12.5, 0);
  295. monthlengths.Add(13, 0);
  296.  
  297. i = 0;
  298.  
  299. if (DaysList[i].dayoftheyear() > 5)
  300. {
  301. LunisolarArrayElement insert = new LunisolarArrayElement(newyear, "Capricorn", 1);
  302. DaysList.Insert(i, insert);
  303. }
  304. else
  305. {
  306. DaysList[i].date = newyear;
  307. DaysList[i].info = "Capricorn";
  308. DaysList[i].number = 1;
  309. }
  310. //Console.WriteLine(DaysList[i]);
  311. i++;
  312. //Console.WriteLine(i);
  313. DaysList[i].info = "Aquarius";
  314. DaysList[i].number = 2;
  315. //Console.WriteLine(DaysList[i]);
  316. i++;
  317. //Console.WriteLine(i);
  318. DaysList[i].info = "Pisces";
  319. DaysList[i].number = 3;
  320. //Console.WriteLine(DaysList[i]);
  321. i++; //i=3;
  322. //Console.WriteLine(i);
  323. if (DaysList[i].info == "moon")
  324. {
  325. DaysList[i].info = "Cetus";
  326. DaysList[i].number = 3.5;
  327. //Console.WriteLine(DaysList[i]);
  328. i++;
  329. }
  330. DaysList[i].info = "Aries";
  331. DaysList[i].number = 4;
  332. //Console.WriteLine(DaysList[i]);
  333. i++;
  334. //Console.WriteLine(i);
  335. DaysList[i].info = "Taurus";
  336. DaysList[i].number = 5;
  337. //Console.WriteLine(DaysList[i]);
  338. i++;
  339. //Console.WriteLine(i);
  340. DaysList[i].info = "Gemini";
  341. DaysList[i].number = 6;
  342. //Console.WriteLine(DaysList[i]);
  343. i++;
  344. //Console.WriteLine(i);
  345. if (DaysList[i].info == "moon")
  346. {
  347. DaysList[i].info = "Lynx";
  348. DaysList[i].number = 6.5;
  349. //Console.WriteLine(DaysList[i]);
  350. i++;
  351. }
  352. DaysList[i].info = "Cancer";
  353. DaysList[i].number = 7;
  354. //Console.WriteLine(DaysList[i]);
  355. i++;
  356. //Console.WriteLine(i);
  357. DaysList[i].info = "Leo";
  358. DaysList[i].number = 8;
  359. //Console.WriteLine(DaysList[i]);
  360. i++;
  361. //Console.WriteLine(i);
  362. DaysList[i].info = "Virgo";
  363. DaysList[i].number = 9;
  364. //Console.WriteLine(DaysList[i]);
  365. i++;
  366. //Console.WriteLine(i);
  367. if (DaysList[i].info == "moon")
  368. {
  369. DaysList[i].info = "Centaurus";
  370. DaysList[i].number = 9.5;
  371. //Console.WriteLine(DaysList[i]);
  372. i++;
  373. }
  374. DaysList[i].info = "Libra";
  375. DaysList[i].number = 10;
  376. //Console.WriteLine(DaysList[i]);
  377. i++;
  378. //Console.WriteLine(i);
  379. DaysList[i].info = "Scorpio";
  380. DaysList[i].number = 11;
  381. //Console.WriteLine(DaysList[i]);
  382. i++;
  383. //Console.WriteLine(i);
  384. DaysList[i].info = "Saggittarius";
  385. DaysList[i].number = 12;
  386. //Console.WriteLine(DaysList[i]);
  387. i++;
  388. //Console.WriteLine(i);
  389. if (DaysList[i].info == "moon")
  390. {
  391. DaysList[i].info = "Opciucius";
  392. DaysList[i].number = 12.5;
  393. //Console.WriteLine(DaysList[i]);
  394. i++;
  395. }
  396. DaysList[i].info = "Mannus";
  397. DaysList[i].number = 13;
  398. //Console.WriteLine(DaysList[i]);
  399.  
  400. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  401. ///
  402.  
  403. //Console.WriteLine("new list");
  404.  
  405. foreach (var item in DaysList)
  406. {
  407.  
  408. //Console.WriteLine(item);
  409.  
  410. }
  411.  
  412.  
  413.  
  414. LunisolarDay[] YearArray = new LunisolarDay[yeardays];
  415.  
  416. i = 0;
  417. int day = 1;
  418. month = 1;
  419. int m_int = 1;
  420. int moonage;
  421. string feast = "Feast of " + DaysList[i].info;
  422. while (i < yeardays)
  423. {
  424. moonage = (int)MoonAge(dt);
  425. YearArray[i] = new LunisolarDay(dt, manuyear, month, day, feast, moonage);
  426. dt = dt.AddDays(1);
  427. day++;
  428. i++;
  429. monthlengths[month]++;
  430. feast = "0";
  431. //Console.WriteLine("DaysList[0]");
  432. //Console.WriteLine(DaysList[0]);
  433. //Console.WriteLine("m_int = " + m_int);
  434. //Console.WriteLine("Days List");
  435. foreach (var item in DaysList)
  436. {
  437. //Console.WriteLine(item);
  438.  
  439. }
  440. //Console.WriteLine("if (" + dt + " == " + DaysList[m_int].date + ")");
  441. if (dt == DaysList[m_int].date)
  442. {
  443. day = 1;
  444. //Console.WriteLine("month before " + month);
  445. month = DaysList[m_int].number;
  446. //Console.WriteLine("month after " + month);
  447. //Console.WriteLine("m_int");
  448. //Console.WriteLine(m_int);
  449. m_int++;
  450. if(m_int > 12)
  451. {
  452. m_int = 0; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  453. }
  454. if (YearArray[i - 1].feast == "none") //out of array bounds exception
  455. {
  456. YearArray[i - 1].feast = "Sabbath of Doors";
  457. }
  458. }
  459. }
  460.  
  461. //Console.WriteLine(monthlengths);
  462.  
  463.  
  464.  
  465.  
  466. LunisolarYear CreatedYear = new LunisolarYear(YearArray, monthlengths);
  467.  
  468. return CreatedYear;
  469. }
  470.  
  471.  
  472. public static LunisolarArrayElement LunisolarFudge(DateTime PreMoon, DateTime Solar, DateTime PostMoon)
  473. {
  474. Object[] ReturnedArray = new Object[5];
  475. int intercalation = 0;
  476. double negative = (Solar - PreMoon).TotalDays;
  477. double positive = (PostMoon - Solar).TotalDays;
  478. int direction;
  479. if (negative > positive)
  480. {
  481. direction = 1;
  482. intercalation = (int)positive;
  483. }
  484. else
  485. {
  486. direction = -1;
  487. intercalation = (int)negative;
  488. }
  489. //Console.WriteLine("negative is " + negative);
  490. //Console.WriteLine("positive is " + positive);
  491. //Console.WriteLine("direction: " + direction);
  492. //Console.WriteLine("magnitude is " + intercalation);
  493. DateTime returndate;
  494. string returninfo = "0";
  495. ////////////////////////////////////////////////////////////////////////////////////////////////////
  496. if (intercalation >= 5)
  497. {
  498. returndate = Solar;
  499. returninfo = "Solar";
  500. }
  501. else if (direction == 1)
  502. {
  503. returndate = PostMoon;
  504. returninfo = "PostMoon";
  505. }
  506. else
  507. {
  508. returndate = PreMoon;
  509. returninfo = "PreMoon";
  510. }
  511. //ReturnedArray[1] = direction;
  512. //ReturnedArray[3] = intercalation;
  513.  
  514. //return ReturnedArray;
  515. ///return ReturnedArray[0];
  516. ///retur
  517. return new LunisolarArrayElement(returndate, returninfo, direction);
  518. }
  519.  
  520.  
  521.  
  522. public static DateTime Monthround(DateTime quarterpoint)
  523. {
  524. DateTime beginning = quarterpoint;
  525. return beginning;
  526. }
  527.  
  528. public static MannicDay[] MannicYear(int year, string calendar)
  529. {
  530. ////Console.WriteLine("Hello World!");
  531.  
  532. ////Console.WriteLine("We are going to convert a date from the gregorian calendar to the Mannic Calendar");
  533.  
  534. bool British = false;
  535.  
  536. if (calendar == "British")
  537. {
  538. British = true;
  539. }
  540.  
  541. /*In England until 1751 the year began on March 25 and used the Julian calendar
  542. * In England and Wales, the legal year 1751 was a short year of 282 days, running from 25 March to 31 December. 1752 began on 1 January.
  543. * Wednesday 2 September 1752 was followed by Thursday 14 September 1752.[c] The year 1752 was thus a short year (355 days) as well.*/
  544.  
  545.  
  546. bool Swedish = false;
  547.  
  548. if (calendar == "Swedish")
  549. {
  550. Swedish = true;
  551. }
  552.  
  553. /*
  554. * In Sweden there was a complicated transition from the Julian to the Gregorian Calendar
  555. * From 1700-1753 there was a complex date conversion, before then it was Julian, after was Gregorian
  556. **/
  557.  
  558. //dt = new DateTime(2018, 7, 24);
  559. ////Console.WriteLine("This is our sample date to start");
  560. ////Console.WriteLine(dt.ToString());
  561.  
  562. ////Console.WriteLine(dt.DayOfYear);
  563.  
  564. //int year = dt.Year;
  565. ////Console.WriteLine(year);
  566.  
  567. //MannicDay[] YearArray = new MannicDay[355];
  568. DateTime Vernal;
  569. DateTime Midsummer;
  570. DateTime Mabon;
  571. DateTime LastJulian = new DateTime(1582, 10, 4, 0, 0, 0);
  572. DateTime FirstGregorian = new DateTime(1582, 10, 15, 0, 0, 0);
  573. DateTime Yule;
  574.  
  575.  
  576.  
  577. bool Gregory = false;
  578.  
  579.  
  580. if ((year == 1582) && (calendar == "?"))
  581. {
  582. Gregory = true;
  583. }
  584.  
  585. if (Gregory == true)
  586. {
  587. //MannicDay[] YearArray = new MannicDay[355];
  588. //1582 had 355 days, not 365
  589. Vernal = new DateTime(1582, 03, 11, 0, 09, 0);
  590. Midsummer = new DateTime(1582, 06, 12, 1, 37, 0);
  591. Mabon = new DateTime(1582, 09, 13, 12, 47, 0);
  592. Yule = new DateTime(1582, 12, 22, 2, 0, 0);
  593. }
  594. else
  595. {
  596. DateTime[] FourPoints = Points(year, calendar);
  597. Vernal = FourPoints[0];
  598. Midsummer = FourPoints[1];
  599. Mabon = FourPoints[2];
  600. Yule = FourPoints[3];
  601. }
  602.  
  603. ////Console.WriteLine("Printing Vernal Midsummer Mabon and Yule");
  604. ////Console.WriteLine(Vernal);
  605. ////Console.WriteLine(Midsummer);
  606. ////Console.WriteLine(Mabon);
  607. ////Console.WriteLine(Yule);
  608.  
  609. ////Console.WriteLine((Yule - Mabon).TotalDays);
  610.  
  611. int winter = Vernal.DayOfYear - 1;
  612. int spring = (int)(Midsummer - Vernal).TotalDays;
  613. int summer = (int)(Mabon - Midsummer).TotalDays;
  614. int fall = (int)(Yule - Mabon).TotalDays;
  615.  
  616.  
  617. ////Console.WriteLine("days in fall");
  618. ////Console.WriteLine(fall);
  619. if (Gregory == true)
  620. {
  621. fall -= 9;
  622. }
  623. DateTime newyeareve = new DateTime(year, 12, 31);
  624. int intercalary = (int)(newyeareve - Yule).TotalDays;
  625.  
  626.  
  627.  
  628.  
  629.  
  630. ////Console.WriteLine("Winter " + winter + " spring " + spring + " summer " + summer + " fall " + fall + " intercalary " + intercalary);
  631.  
  632. // other important numbers
  633.  
  634. //int preEaster = (int)(Easter - Vernal).TotalDays;
  635. //int preHannukkah = (int)(HannukahBeginning - Mabon).TotalDays;
  636. //int preThanksgiving = (int)(Thanksgiving - Mabon).TotalDays;
  637.  
  638. int Cap = 0;
  639. int Aqua = 0;
  640. int Pis = 0;
  641. int Ari = 0;
  642. int Tau = 0;
  643. int Gem = 0;
  644. int Can = 0;
  645. int Leo = 0;
  646. int Vir = 0;
  647. int Lib = 0;
  648. int Sco = 0;
  649. int Sag = 0;
  650. int Manu = 0;
  651.  
  652. //days short in season are taken from first month
  653. //extra days in a season are put in the last month
  654.  
  655. int wintersmudge = winter - 90;
  656. if (wintersmudge < 0)
  657. {
  658. Cap = wintersmudge;
  659. }
  660. else
  661. {
  662. Pis = wintersmudge;
  663. }
  664.  
  665. int springsmudge = spring - 90;
  666. if (springsmudge < 0)
  667. {
  668. Ari = springsmudge;
  669. }
  670. else
  671. {
  672. Gem = springsmudge;
  673. }
  674.  
  675. int summersmudge = summer - 90;
  676. if (summersmudge < 0)
  677. {
  678. Can = summersmudge;
  679. }
  680. else
  681. {
  682. Vir = summersmudge;
  683. }
  684.  
  685. int fallsmudge = fall - 90;
  686. if (fallsmudge < 0)
  687. {
  688. Lib = fallsmudge;
  689. }
  690. else
  691. {
  692. Sag = fallsmudge;
  693. }
  694.  
  695. Cap += 30;
  696. Aqua = 30;
  697. Pis += 30;
  698. Ari += 30;
  699. Tau = 30;
  700. Gem += 30;
  701. Can += 30;
  702. Leo = 30;
  703. Vir += 30;
  704. Lib += 30;
  705. Sco = 30;
  706. Sag += 30;
  707. Manu = intercalary;
  708.  
  709. ////Console.WriteLine("Cap");
  710. ////Console.WriteLine(Cap);
  711. ////Console.WriteLine("Aqua");
  712. ////Console.WriteLine(Aqua);
  713. ////Console.WriteLine("Pis");
  714. ////Console.WriteLine(Pis);
  715. ////Console.WriteLine("Ari");
  716. ////Console.WriteLine(Ari);
  717. ////Console.WriteLine("Tau");
  718. ////Console.WriteLine(Tau);
  719. ////Console.WriteLine("Gem");
  720. ////Console.WriteLine(Gem);
  721. ////Console.WriteLine("Can");
  722. ////Console.WriteLine(Can);
  723. ////Console.WriteLine("Leo");
  724. ////Console.WriteLine(Leo);
  725. ////Console.WriteLine("Vir");
  726. ////Console.WriteLine(Vir);
  727. ////Console.WriteLine("Lib");
  728. ////Console.WriteLine(Lib);
  729. ////Console.WriteLine("Sco");
  730. ////Console.WriteLine(Sco);
  731. ////Console.WriteLine("Sag");
  732. ////Console.WriteLine(Sag);
  733. ////Console.WriteLine("Manu");
  734. ////Console.WriteLine(Manu);
  735.  
  736. int yeardays;
  737.  
  738.  
  739. yeardays = newyeareve.DayOfYear;
  740. ////Console.WriteLine("how many days in the year");
  741. ////Console.WriteLine(yeardays);
  742. //yeardays = Cap + Aqua + Pis + Ari + Tau + Gem + Can + Leo + Vir + Lib + Sco + Sag + Manu;
  743.  
  744. if (Gregory == true)
  745. {
  746. ////Console.WriteLine("1582 yeardays calculated");
  747. ////Console.WriteLine(yeardays);
  748. yeardays = 355;
  749. }
  750.  
  751.  
  752. int holidays = 1 + (spring % 30) + (summer % 30) + (fall % 30) + Manu;
  753.  
  754. ////Console.WriteLine(Cap);
  755. ////Console.WriteLine(Aqua);
  756. ////Console.WriteLine(Pis);
  757. ////Console.WriteLine(Ari);
  758. ////Console.WriteLine(Tau);
  759. ////Console.WriteLine(Gem);
  760. ////Console.WriteLine(Can);
  761. ////Console.WriteLine(Leo);
  762. ////Console.WriteLine(Vir);
  763. ////Console.WriteLine(Lib);
  764. ////Console.WriteLine(Sco);
  765. ////Console.WriteLine(Sag);
  766. ////Console.WriteLine(Manu);
  767. ////Console.WriteLine(yeardays);
  768. ////Console.WriteLine(holidays);
  769.  
  770. MannicDay[] YearArray = new MannicDay[yeardays];
  771.  
  772. int i = 0;
  773. int month = 1;
  774. int day = 1;
  775. string feast = "none";
  776. int monthdays = Cap;
  777.  
  778. //filling the array with days
  779.  
  780. DateTime Gregorian = new DateTime(year, 1, 1);
  781.  
  782. while (i < yeardays)
  783. {
  784. //getting inputs
  785. //public MannicDay (DateTime Gregorian, int dayoftheyear, int year, int month, int day)
  786. int dayoftheyear = i + 1;
  787. //Gregorian Calendar dependent dates
  788. if ((Gregorian.Month == 12) && (Gregorian.Day == 25))
  789. {
  790. feast = "Gregorian Christmas";
  791. }
  792. //Mannic feasts/Holidays
  793. if (month == 13)
  794. {
  795. switch (day)
  796. {
  797. case 1:
  798. feast = "1st Blessing of Manu";
  799. break;
  800. case 2:
  801. feast = "2nd Blessing of Manu";
  802. break;
  803. case 3:
  804. feast = "3rd Blessing of Manu";
  805. break;
  806. case 5:
  807. feast = "Christmas of Manu";
  808. break;
  809. default:
  810. feast = (day + "th Blessing of Manu");
  811. break;
  812. }
  813. }
  814. if (day == 1)
  815. {
  816. switch (month)
  817. {
  818. case 1:
  819. feast = "Feast of Capricorn"; break;
  820. case 2:
  821. feast = "Feast of Aquarius"; break;
  822. case 3:
  823. feast = "Feast of Pisces"; break;
  824. case 4:
  825. feast = "Feast of Aries"; break;
  826. case 5:
  827. feast = "Feast of Taurus"; break;
  828. case 6:
  829. feast = "Feast of Gemini"; break;
  830. case 7:
  831. feast = "Feast of Cancer"; break;
  832. case 8:
  833. feast = "Feast of Leo"; break;
  834. case 9:
  835. feast = "Feast of Virgo"; break;
  836. case 10:
  837. feast = "Feast of Libra"; break;
  838. case 11:
  839. feast = "Feast of Scorpio"; break;
  840. case 12:
  841. feast = "Feast of Saggittarius"; break;
  842. case 13:
  843. feast = "Feast of Manu"; break;
  844. }
  845. }
  846. if ((monthdays < 30) && (day == monthdays) && (month < 13))
  847. {
  848. feast = "Sabbath of Doors";
  849. }
  850. if (Gregorian == newyeareve)
  851. {
  852. feast = "Feast of Yemo";
  853. }
  854. if (day > 30)
  855. {
  856. int ordinal = day - 30;
  857. string monthname = "Capricorn";
  858. switch (month)
  859. {
  860. case 1:
  861. monthname = "Capricorn"; break;
  862. case 2:
  863. monthname = "Aquarius"; break;
  864. case 3:
  865. monthname = "Pisces"; break;
  866. case 4:
  867. monthname = "Aries"; break;
  868. case 5:
  869. monthname = "Taurus"; break;
  870. case 6:
  871. monthname = "Gemini"; break;
  872. case 7:
  873. monthname = "Cancer"; break;
  874. case 8:
  875. monthname = "Leo"; break;
  876. case 9:
  877. monthname = "Virgo"; break;
  878. case 10:
  879. monthname = "Libra"; break;
  880. case 11:
  881. monthname = "Scorpio"; break;
  882. case 12:
  883. monthname = "Saggittarius"; break;
  884. case 13:
  885. monthname = "Mannus"; break;
  886. }
  887.  
  888. switch (ordinal)
  889. {
  890. case 1:
  891. feast = ("1st Blessing of " + monthname);
  892. break;
  893. case 2:
  894. feast = ("2nd Blessing of " + monthname);
  895. break;
  896. case 3:
  897. feast = ("3rd Blessing of " + monthname);
  898. break;
  899. default:
  900. feast = (ordinal + "th Blessing of " + monthname);
  901. break;
  902. }
  903. }
  904. if ((month == 12) && (day == monthdays))
  905. {
  906. feast = "Eve of the Solstice";
  907. }
  908. //initialize object
  909. YearArray[i] = new MannicDay(Gregorian, dayoftheyear, year, month, day, feast);
  910. ////Console.WriteLine(YearArray[i].ToString());
  911. //move calendar forward
  912. day++;
  913. if (month == 13)
  914. {
  915.  
  916. }
  917. else if (monthdays < day)
  918. {
  919. day = 1;
  920. month++;
  921. switch (month)
  922. {
  923. case 1:
  924. monthdays = Cap; break;
  925. case 2:
  926. monthdays = Aqua; break;
  927. case 3:
  928. monthdays = Pis; break;
  929. case 4:
  930. monthdays = Ari; break;
  931. case 5:
  932. monthdays = Tau; break;
  933. case 6:
  934. monthdays = Gem; break;
  935. case 7:
  936. monthdays = Can; break;
  937. case 8:
  938. monthdays = Leo; break;
  939. case 9:
  940. monthdays = Vir; break;
  941. case 10:
  942. monthdays = Lib; break;
  943. case 11:
  944. monthdays = Sco; break;
  945. case 12:
  946. monthdays = Sag; break;
  947. case 13:
  948. monthdays = Manu; break;
  949. }
  950. }
  951. //reset variables
  952. if ((Gregory == true) && (Gregorian == LastJulian))
  953. {
  954. Gregorian = FirstGregorian;
  955. }
  956. else { Gregorian = Gregorian.AddDays(1); }
  957.  
  958. feast = "none";
  959. i++;
  960. }
  961. //returning date
  962.  
  963. return YearArray;
  964. //YearArray
  965. /*
  966. int i = 0;
  967. int month = 1;
  968. int day = 1;
  969. string feast = "none";
  970. */
  971. }
  972.  
  973. public static DateTime roundtomidnight(DateTime dt)
  974. {
  975. int year = dt.Year;
  976. int month = dt.Month;
  977. int day = dt.Day;
  978. int hour = dt.Hour;
  979. int minute = dt.Minute;
  980.  
  981. if (hour > 12)
  982. {
  983. day++;
  984. }
  985. DateTime rounded = new DateTime(year, month, day, 0, 0, 0);
  986. return rounded;
  987. }
  988.  
  989. //https://www.codeproject.com/Articles/100174/Calculate-and-Draw-Moon-Phase Got this code from here
  990.  
  991. public static int JulianDate(int d, int m, int y)
  992. {
  993. int mm, yy;
  994. int k1, k2, k3;
  995. int j;
  996.  
  997. yy = y - (int)((12 - m) / 10);
  998. mm = m + 9;
  999. if (mm >= 12)
  1000. {
  1001. mm = mm - 12;
  1002. }
  1003. k1 = (int)(365.25 * (yy + 4712));
  1004. k2 = (int)(30.6001 * mm + 0.5);
  1005. k3 = (int)((int)((yy / 100) + 49) * 0.75) - 38;
  1006. // 'j' for dates in Julian calendar:
  1007. j = k1 + k2 + d + 59;
  1008. if (j > 2299160)
  1009. {
  1010. // For Gregorian calendar:
  1011. j = j - k3; // 'j' is the Julian date at 12h UT (Universal Time)
  1012. }
  1013. return j;
  1014. }
  1015.  
  1016. public static double MoonAge(DateTime date)
  1017. {
  1018. int day = date.Day;
  1019. int month = date.Month;
  1020. int year = date.Year;
  1021. return MoonAge(day, month, year);
  1022. }
  1023.  
  1024. public static double MoonAge(int d, int m, int y)
  1025. {
  1026. int j = JulianDate(d, m, y);
  1027. //Calculate the approximate phase of the moon
  1028. var ip = (j + 4.867) / 29.53059;
  1029. ip = ip - Math.Floor(ip);
  1030. //After several trials I've seen to add the following lines,
  1031. //which gave the result was not bad
  1032. double ag;
  1033. if (ip < 0.5)
  1034. ag = ip * 29.53059 + 29.53059 / 2;
  1035. else
  1036. ag = ip * 29.53059 - 29.53059 / 2;
  1037. // Moon's age in days
  1038. ag = Math.Floor(ag) + 1;
  1039. return ag;
  1040. }
  1041.  
  1042. public static DateTime[] Moons(int year)
  1043. {
  1044. DateTime[] MoonsArray = new DateTime[13];
  1045. int i = 0;
  1046. int j = 0;
  1047. DateTime date = new DateTime(year, 1, 1, 0, 0, 0);
  1048. DateTime newyear = new DateTime(year, 12, 31, 0, 0, 0);
  1049. int yeardays = newyear.DayOfYear;
  1050. while (i < yeardays)
  1051. {
  1052. if (MoonAge(date) == 1)
  1053. {
  1054. MoonsArray[j] = date;
  1055. j++;
  1056. }
  1057. date = date.AddDays(1);
  1058. i++;
  1059. }
  1060. return MoonsArray;
  1061. }
  1062.  
  1063. public static DateTime CalculateDate(double val, string calendar, int date)
  1064. {
  1065. double ut;
  1066. int jdn;
  1067. int year;
  1068. int month;
  1069. int day;
  1070. int hour;
  1071. int minute;
  1072. bool julian;
  1073. int x;
  1074. int z;
  1075. int m;
  1076. int d;
  1077. int y;
  1078. int daysPer400Years = 146097;
  1079. int fudgedDaysPer4000Years = 1460970 + 31;
  1080.  
  1081. val += 0.5; // Convert astronomical JDN to chronological
  1082.  
  1083. jdn = (int)Math.Floor(val);
  1084. ut = val - jdn;
  1085. //julian = (jdn <= DefineConstants.LASTJULJDN);
  1086. switch (calendar)
  1087. {
  1088. case "Gregorian": //gregorian
  1089. julian = false;
  1090. break;
  1091. case "Julian": //julian
  1092. julian = true;
  1093. break;
  1094. // possibly add more calendars as we go along, converting them to Gregorian first and then to Mannic
  1095. case "British": //British Old Style Calendar
  1096. //break;
  1097. case "Swedish": //Swedish
  1098. //break;
  1099. default: //julian gregorian unknown
  1100. if (date <= 1582)
  1101. {
  1102. julian = true;
  1103. }
  1104. else
  1105. {
  1106. julian = false;
  1107. }
  1108. break;
  1109. }
  1110. x = jdn + 68569;
  1111.  
  1112. if (julian == true)
  1113. {
  1114. x += 38;
  1115. daysPer400Years = 146100;
  1116. fudgedDaysPer4000Years = 1461000 + 1;
  1117. }
  1118.  
  1119. z = 4 * x / daysPer400Years;
  1120. x = x - (daysPer400Years * z + 3) / 4;
  1121. y = 4000 * (x + 1) / fudgedDaysPer4000Years;
  1122. x = x - 1461 * y / 4 + 31;
  1123. m = 80 * x / 2447;
  1124. d = x - 2447 * m / 80;
  1125. x = m / 11;
  1126. m = m + 2 - 12 * x;
  1127. y = 100 * (z - 49) + y + x;
  1128. year = (int)y;
  1129. month = (int)m;
  1130. day = (int)d;
  1131. if (year <= 0) // adjust BC years
  1132. {
  1133. year--;
  1134. }
  1135.  
  1136. hour = (int)(ut * 24);
  1137. minute = (int)((ut * 24 - hour) * 60); // Accurate to about 15 minutes c. 2000 CE.
  1138.  
  1139. //retval.Format("%02d-%02d-%4d %02d:%02d GMT", day, month, year, hour, minute);
  1140.  
  1141. DateTime retval = new DateTime(year, month, day, hour, minute, 0);
  1142.  
  1143. return (retval);
  1144. }
  1145.  
  1146. public static DateTime[] Points(int year, string calendar)
  1147. {
  1148. DateTime[] FourPoints = PointsWithTime(year, calendar);
  1149. DateTime[] FixedTime = new DateTime[4];
  1150. FixedTime[0] = roundtomidnight(FourPoints[0]);
  1151. FixedTime[1] = roundtomidnight(FourPoints[1]);
  1152. FixedTime[2] = roundtomidnight(FourPoints[2]);
  1153. FixedTime[3] = roundtomidnight(FourPoints[3]);
  1154. return FixedTime;
  1155. }
  1156.  
  1157. public static DateTime[] PointsWithTime(int input_year, string calendar)
  1158. {
  1159. DateTime[] points = new DateTime[4];
  1160. double m;
  1161. double ve;
  1162. double ss;
  1163. double ae;
  1164. double ws;
  1165.  
  1166. m = ((double)input_year - 2000.0) / 1000.0;
  1167. ve = 2451623.80984 + 365242.37404 * m + 0.05169 * m * m - 0.00411 * m * m * m - 0.00057 * m * m * m * m;
  1168.  
  1169.  
  1170. points[0] = CalculateDate(ve, calendar, input_year);
  1171. ss = 2451716.56767 + 365241.62603 * m + 0.00325 * m * m + 0.00888 * m * m * m - 0.00030 * m * m * m * m;
  1172.  
  1173.  
  1174. points[1] = CalculateDate(ss, calendar, input_year);
  1175. ae = 2451810.21715 + 365242.01767 * m - 0.11575 * m * m + 0.00337 * m * m * m + 0.00078 * m * m * m * m;
  1176.  
  1177.  
  1178. points[2] = CalculateDate(ae, calendar, input_year);
  1179. ws = 2451900.05952 + 365242.74049 * m - 0.06223 * m * m - 0.00823 * m * m * m + 0.00032 * m * m * m * m;
  1180.  
  1181.  
  1182. points[3] = CalculateDate(ws, calendar, input_year);
  1183.  
  1184. return points;
  1185. }
  1186.  
  1187. public static string textform(int input)
  1188. {
  1189. string suffix;
  1190. int end = input % 100;
  1191. int ten = 10;
  1192. if ((end / ten) == 1)
  1193. {
  1194. suffix = "th";
  1195. }
  1196. else
  1197. {
  1198. end %= 10;
  1199. switch (end)
  1200. {
  1201. case 1:
  1202. suffix = "st";
  1203. break;
  1204. case 2:
  1205. suffix = "nd";
  1206. break;
  1207. case 3:
  1208. suffix = "rd";
  1209. break;
  1210. default:
  1211. suffix = "th";
  1212. break;
  1213. }
  1214. }
  1215.  
  1216. return (input + suffix);
  1217.  
  1218. }
  1219.  
  1220. public static MannicDay create(int year, int month, int day)
  1221. {
  1222. int gregyear;
  1223. if (year > 10000)
  1224. {
  1225. gregyear = year - 10000;
  1226. }
  1227. else
  1228. {
  1229. gregyear = year - 10001;
  1230. }
  1231.  
  1232. //MannicDay[] CreatedYear; //= Mithralib.MannicYear(gregyear, 1);
  1233. //MannicYear
  1234.  
  1235. MannicDay[] YearArray = MannicYear(year, "?");
  1236.  
  1237. int count = 0;
  1238. int dayofyear = 0;
  1239. foreach (MannicDay element in YearArray)
  1240. {
  1241. count++;
  1242. ////Console.WriteLine($"Element #{count}: {element}");
  1243.  
  1244. if ((element.month == month) && (element.day == day))
  1245. {
  1246. dayofyear = element.dayoftheyear;
  1247. }
  1248. }
  1249.  
  1250. if (dayofyear == 0)
  1251. {
  1252. return null;
  1253. }
  1254.  
  1255. //MannicDay(DateTime Gregorian, int dayoftheyear, int year, int month, int day, string feast)
  1256.  
  1257. MannicDay createdday = YearArray[dayofyear];
  1258. return createdday;
  1259.  
  1260. }
  1261.  
  1262. public static DateTime Convertback(MannicDay date)
  1263. {
  1264. return date.Gregorian;
  1265. }
  1266.  
  1267. }
  1268.  
  1269.  
  1270. public class MannicDay
  1271. {
  1272. public DateTime Gregorian;
  1273. public int dayoftheyear;
  1274. public int year;
  1275. public int month;
  1276. public int day;
  1277. public string feast;
  1278.  
  1279. public MannicDay(DateTime Gregorian, int dayoftheyear, int year, int month, int day, string feast)
  1280. {
  1281. this.Gregorian = Gregorian;
  1282. this.dayoftheyear = dayoftheyear;
  1283. if (year >= 1)
  1284. {
  1285. this.year = year + 10000;
  1286. }
  1287. else
  1288. {
  1289. this.year = year + 1001;
  1290. }
  1291. this.month = month;
  1292. this.day = day;
  1293. this.feast = feast;
  1294. }
  1295.  
  1296. public MannicDay()
  1297. {
  1298.  
  1299. }
  1300.  
  1301. public string getmonthname()
  1302. {
  1303. switch (this.month)
  1304. {
  1305. case 1:
  1306. return "Capricorn";
  1307. case 2:
  1308. return "Aquarius";
  1309. case 3:
  1310. return "Pisces";
  1311. case 4:
  1312. return "Aries";
  1313. case 5:
  1314. return "Taurus";
  1315. case 6:
  1316. return "Gemini";
  1317. case 7:
  1318. return "Cancer";
  1319. case 8:
  1320. return "Leo";
  1321. case 9:
  1322. return "Virgo";
  1323. case 10:
  1324. return "Libra";
  1325. case 11:
  1326. return "Scorpio";
  1327. case 12:
  1328. return "Saggittarius";
  1329. case 13:
  1330. return "Mannus";
  1331. }
  1332. return "?";
  1333. }
  1334.  
  1335. public string monthabbreviation()
  1336. {
  1337. switch (this.month)
  1338. {
  1339. case 1:
  1340. return "Cap";
  1341. case 2:
  1342. return "Aqua";
  1343. case 3:
  1344. return "Pis";
  1345. case 4:
  1346. return "Ari";
  1347. case 5:
  1348. return "Tau";
  1349. case 6:
  1350. return "Gem";
  1351. case 7:
  1352. return "Can";
  1353. case 8:
  1354. return "Leo";
  1355. case 9:
  1356. return "Vir";
  1357. case 10:
  1358. return "Lib";
  1359. case 11:
  1360. return "Sco";
  1361. case 12:
  1362. return "Sag";
  1363. case 13:
  1364. return "Manu";
  1365. }
  1366. return "?";
  1367. }
  1368.  
  1369. public string getmonthsymbol()
  1370. {
  1371. switch (this.month)
  1372. {
  1373. case 1:
  1374. return "♑";
  1375. case 2:
  1376. return "♒";
  1377. case 3:
  1378. return "♓️";
  1379. case 4:
  1380. return "♈";
  1381. case 5:
  1382. return "♉";
  1383. case 6:
  1384. return "♊";
  1385. case 7:
  1386. return "♋️";
  1387. case 8:
  1388. return "♌";
  1389. case 9:
  1390. return "♍";
  1391. case 10:
  1392. return "♎";
  1393. case 11:
  1394. return "♏";
  1395. case 12:
  1396. return "♐";
  1397. case 13:
  1398. return "🎄";
  1399. }
  1400. return "?";
  1401. }
  1402.  
  1403. public string getfeast()
  1404. {
  1405. return this.feast;
  1406. }
  1407.  
  1408. public bool feastbool()
  1409. {
  1410. if (string.Equals(this.feast, "none") == true)
  1411. {
  1412. return false;
  1413. }
  1414. else
  1415. {
  1416. return true;
  1417. }
  1418. }
  1419.  
  1420. public bool dayoff()
  1421. {
  1422. if (this.feastbool() == true)
  1423. {
  1424. return true;
  1425. }
  1426. if ((this.day % 5) == 1)
  1427. {
  1428. return true;
  1429. }
  1430. else
  1431. {
  1432. return false;
  1433. }
  1434. }
  1435.  
  1436. public DateTime getGregorian()
  1437. {
  1438. return this.Gregorian;
  1439. }
  1440.  
  1441. public int getmonth()
  1442. {
  1443. return this.month;
  1444. }
  1445.  
  1446. public int getyear()
  1447. {
  1448. return this.year;
  1449. }
  1450.  
  1451. public int getday()
  1452. {
  1453. return this.day;
  1454. }
  1455.  
  1456. public int getdayoftheyear()
  1457. {
  1458. return this.dayoftheyear;
  1459. }
  1460.  
  1461. public string ymd()
  1462. {
  1463. //return string("" + this.year + "/" + this.month + "/" + this.day);
  1464. string output = ("" + this.year + "/" + this.month + "/" + this.day);
  1465. return output;
  1466. }
  1467.  
  1468. public string dmy()
  1469. {
  1470. string output = ("" + this.day + "/" + this.month + "/" + this.year);
  1471. return output;
  1472. }
  1473.  
  1474. public string mdy()
  1475. {
  1476. string output = ("" + this.month + "/" + this.day + "/" + this.year);
  1477. return output;
  1478. }
  1479.  
  1480. public string weekday()
  1481. {
  1482. switch (this.day % 5)
  1483. {
  1484. case 1:
  1485. return "Adonai";
  1486. case 2:
  1487. return "Mithra";
  1488. case 3:
  1489. return "Azoth";
  1490. case 4:
  1491. return "Oxa";
  1492. default:
  1493. return "Manu";
  1494. }
  1495. }
  1496.  
  1497. override public string ToString()
  1498. {
  1499. string s0 = ("" + this.getdayoftheyear());
  1500. string s1 = this.ymd();
  1501. string s2 = this.getmonthsymbol();
  1502. string s3 = this.getmonthname();
  1503. string s4 = this.feast;
  1504. string greg = this.Gregorian.ToString();
  1505. string text = ("day " + s0 + " " + greg + " " + s1 + " " + s3 + " " + s4);
  1506. return text;
  1507. }
  1508.  
  1509. public string display()
  1510. {
  1511. string weekday = this.weekday();
  1512. int day = this.getday();
  1513. string dayth = textform(day);
  1514. string month = this.getmonthname();
  1515. int year = this.getyear();
  1516. string yearth = textform(year);
  1517. string display = (weekday + "day " + month + " " + dayth + ", of the " + yearth + " year of Manu");
  1518. return display;
  1519. }
  1520.  
  1521. public static string textform(int input)
  1522. {
  1523. string suffix;
  1524. int end = input % 100;
  1525. int ten = 10;
  1526. if ((end / ten) == 1)
  1527. {
  1528. suffix = "th";
  1529. }
  1530. else
  1531. {
  1532. end %= 10;
  1533. switch (end)
  1534. {
  1535. case 1:
  1536. suffix = "st";
  1537. break;
  1538. case 2:
  1539. suffix = "nd";
  1540. break;
  1541. case 3:
  1542. suffix = "rd";
  1543. break;
  1544. default:
  1545. suffix = "th";
  1546. break;
  1547. }
  1548. }
  1549.  
  1550. return (input + suffix);
  1551.  
  1552. //MannicDay[] YearArray = MannicYear(year, 1);
  1553.  
  1554. }
  1555.  
  1556.  
  1557. }
  1558.  
  1559. public class LunisolarArrayElement : IComparable<LunisolarArrayElement>
  1560. {
  1561. public DateTime date;
  1562. public string info;
  1563. public double number;
  1564. public LunisolarArrayElement(DateTime date, string info, double number)
  1565. {
  1566. this.date = date;
  1567. this.info = info;
  1568. this.number = number;
  1569. }
  1570.  
  1571. //public int CompareTo([AllowNull] LunisolarArrayElement other)
  1572.  
  1573. public int CompareTo(LunisolarArrayElement other)
  1574. {
  1575. return this.dayoftheyear().CompareTo(other.dayoftheyear());
  1576. }
  1577.  
  1578. public int dayoftheyear()
  1579. {
  1580. if (this.number == 999)
  1581. {
  1582. return 999;
  1583. }
  1584. return this.date.DayOfYear; //I want to be able to sort based on day of the year
  1585. }
  1586. public DateTime getdate()
  1587. {
  1588. return this.date;
  1589. }
  1590. public string getinfo()
  1591. {
  1592. return this.info;
  1593. }
  1594.  
  1595. public bool isquarter()
  1596. {
  1597. if (this.info == "0")
  1598. {
  1599. return false;
  1600. }
  1601. if (this.info == "moon")
  1602. {
  1603. return false;
  1604. }
  1605. else
  1606. {
  1607. return true;
  1608. }
  1609. }
  1610.  
  1611. public override string ToString()
  1612. {
  1613. string objectinfo;
  1614. objectinfo = (" " + this.dayoftheyear() + " " + this.date + " " + this.info + " number: " + this.number);
  1615. return objectinfo;
  1616. }
  1617. }
  1618.  
  1619. public class LunisolarYear
  1620. {
  1621. public LunisolarDay[] DaysArray;
  1622. public Dictionary<double, int> monthdays;
  1623.  
  1624. public LunisolarYear(LunisolarDay[] DaysArray, Dictionary<double, int> monthdays)
  1625. {
  1626. this.DaysArray = DaysArray;
  1627. this.monthdays = monthdays;
  1628. }
  1629. }
  1630.  
  1631.  
  1632. public class LunisolarDay
  1633. {
  1634. //DateTime Gregorian, int dayoftheyear, int year, int month, int day, string feast)
  1635. public DateTime Gregorian;
  1636. public int year;
  1637. public double month;
  1638. public int day;
  1639. public string feast;
  1640. public double moonage;
  1641. public LunisolarDay(DateTime Gregorian, int year, double month, int day, string feast, double moonage)
  1642. {
  1643. this.Gregorian = Gregorian;
  1644. //this.dayoftheyear = Gregorian.DayOfYear;
  1645. // dt, manuyear, month, day, feast, moonage
  1646. this.year = year;
  1647. this.month = month;
  1648. this.day = day;
  1649. this.feast = feast;
  1650. this.moonage = moonage;
  1651. //this.month_name = month_name;
  1652. }
  1653.  
  1654. public string monthnames()
  1655. {
  1656. string[] weekDays = new string[] { "Capricorn", "Aquarius", "Pisces", "Cetus", "Aries", "Taurus", "Gemini", "Lynx", "Cancer", "Leo", "Virgo", "Centaurus", "Libra", "Scorpio", "Saggittarius", "Opciucius", "Mannus" };
  1657. //string[] names =
  1658. switch (this.month)
  1659. {
  1660. case 1:
  1661. return "Capricorn";
  1662. case 2:
  1663. return "Aquarius";
  1664. case 3:
  1665. return "Pisces";
  1666. case 3.5:
  1667. return "Cetus";
  1668. case 4:
  1669. return "Aries";
  1670. case 5:
  1671. return "Taurus";
  1672. case 6:
  1673. return "Gemini";
  1674. case 6.5:
  1675. return "Lynx";
  1676. case 7:
  1677. return "Cancer";
  1678. case 8:
  1679. return "Leo";
  1680. case 9:
  1681. return "Virgo";
  1682. case 9.5:
  1683. return "Centaurus";
  1684. case 10:
  1685. return "Libra";
  1686. case 11:
  1687. return "Scorpio";
  1688. case 12:
  1689. return "Saggittarius";
  1690. case 12.5:
  1691. return "Ophiucius";
  1692. case 13:
  1693. return "Mannus";
  1694. default:
  1695. return "unknown";
  1696. }
  1697. }
  1698.  
  1699. public string ymd()
  1700. {
  1701. string ymd = this.year + "/" + this.month + "/" + this.day;
  1702. return ymd;
  1703. }
  1704.  
  1705. override public string ToString()
  1706. {
  1707. int dayoftheyear = this.Gregorian.DayOfYear;
  1708. DateTime date = this.Gregorian;
  1709. string ymd = this.ymd();
  1710. string text = this.display();
  1711. string returnstring = dayoftheyear + " " + date + " " + ymd + " " + text;
  1712. return returnstring;
  1713. }
  1714.  
  1715. public string display()
  1716. {
  1717. string weekday = this.weekday();
  1718. int day = this.day;
  1719. string dayth = textform(day);
  1720. string monthname = this.monthnames();
  1721. int year = this.year;
  1722. string yearth = textform(year);
  1723. string day_info;
  1724. if (this.feast == "0")
  1725. {
  1726. day_info = weekday + "day";
  1727. }
  1728. else
  1729. {
  1730. day_info = this.feast;
  1731. }
  1732. string display = (day_info + " " + monthname + " " + dayth + ", of the " + yearth + " year of Manu");
  1733. return display;
  1734. }
  1735.  
  1736. public string weekday()
  1737. {
  1738. switch (this.day % 5)
  1739. {
  1740. case 1:
  1741. return "Adonai";
  1742. case 2:
  1743. return "Mithra";
  1744. case 3:
  1745. return "Azoth";
  1746. case 4:
  1747. return "Oxa";
  1748. default:
  1749. return "Manu";
  1750. }
  1751. }
  1752.  
  1753. public static string textform(int input)
  1754. {
  1755. string suffix;
  1756. int end = input % 100;
  1757. int ten = 10;
  1758. if ((end / ten) == 1)
  1759. {
  1760. suffix = "th";
  1761. }
  1762. else
  1763. {
  1764. end %= 10;
  1765. switch (end)
  1766. {
  1767. case 1:
  1768. suffix = "st";
  1769. break;
  1770. case 2:
  1771. suffix = "nd";
  1772. break;
  1773. case 3:
  1774. suffix = "rd";
  1775. break;
  1776. default:
  1777. suffix = "th";
  1778. break;
  1779. }
  1780. }
  1781.  
  1782. return (input + suffix);
  1783.  
  1784. //MannicDay[] YearArray = MannicYear(year, 1);
  1785.  
  1786. }
  1787. }
  1788.  
  1789. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement