Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleCalendar
- {
- class Program
- {
- static void Main(string[] args)
- {
- DateTime date = DateTime.Now;
- //DateTime date = new DateTime(1970, 1, 1);
- Console.WriteLine(ConvertToMannic(date));
- }
- /*
- *I got this program working to my desires
- It works perfectly well for any dates before 1582 in the Gregorian Calendar.
- In later development I am contemplating what to do before 1582.
- My current idea is to base years off of the Julian Calendar in the way 1582 works in this calendar. And I will go with the Julian Calendar to Jan 1st 1 AD
- From there I will then eliminate the month of Manu to have it simply be Capricorn and go like that for BC years
- Alternatively if I find that proleptic Gregorian is the most common system for dates then I will have the month of Manu not exist before 11582, because if the year isn't preserved to primary sources anyways then there isn't a point in preserving the year to the Gregorian calendar
- In the future I want to reform the Mannic calendar to merge the month of Manu into Capricorn. There will be a short year, and then the feast of Manu will be the New Year rather than the first day of the Month of Manu
- */
- public static MannicDay ConvertToMannic(DateTime dt)
- {
- return ConvertToMannic(dt, 0);
- }
- public static MannicDay ConvertToMannic(DateTime dt, int calendar)
- {
- //Console.WriteLine("Hello World!");
- //Console.WriteLine("We are going to convert a date from the gregorian calendar to the Mannic Calendar");
- bool British = false;
- if (calendar == 3)
- {
- British = true;
- }
- /*In England until 1751 the year began on March 25 and used the Julian calendar
- * 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.
- * Wednesday 2 September 1752 was followed by Thursday 14 September 1752.[c] The year 1752 was thus a short year (355 days) as well.*/
- bool Swedish = false;
- if (calendar == 4)
- {
- Swedish = true;
- }
- /*
- * In Sweden there was a complicated transition from the Julian to the Gregorian Calendar
- * From 1700-1753 there was a complex date conversion, before then it was Julian, after was Gregorian
- **/
- //dt = new DateTime(2018, 7, 24);
- //Console.WriteLine("This is our sample date to start");
- //Console.WriteLine(dt.ToString());
- int day_of_the_year_to_convert = dt.DayOfYear - 1;
- //Console.WriteLine(dt.DayOfYear);
- int year = dt.Year;
- //Console.WriteLine(year);
- //MannicDay[] MannicYear = new MannicDay[355];
- DateTime Vernal;
- DateTime Midsummer;
- DateTime Mabon;
- DateTime LastJulian = new DateTime(1582, 10, 4, 0, 0, 0);
- DateTime FirstGregorian = new DateTime(1582, 10, 15, 0, 0, 0);
- DateTime Yule;
- if ((year == 1582) && (dt.Month == 10) && (dt.Day > 4) && (dt.Day < 15) )
- {
- calendar = 1;
- }
- bool Gregory = false;
- if ((year == 1582) && (calendar == 0))
- {
- Gregory = true;
- }
- if (Gregory == true)
- {
- //MannicDay[] MannicYear = new MannicDay[355];
- //1582 had 355 days, not 365
- Vernal = new DateTime(1582, 03, 11, 0, 09, 0);
- Midsummer = new DateTime(1582, 06, 12, 1, 37, 0);
- Mabon = new DateTime(1582, 09, 13, 12, 47, 0);
- Yule = new DateTime(1582, 12, 22, 2, 0, 0);
- }
- else
- {
- DateTime[] FourPoints = Points(year, calendar);
- Vernal = FourPoints[0];
- Midsummer = FourPoints[1];
- Mabon = FourPoints[2];
- Yule = FourPoints[3];
- }
- //Console.WriteLine("Printing Vernal Midsummer Mabon and Yule");
- //Console.WriteLine(Vernal);
- //Console.WriteLine(Midsummer);
- //Console.WriteLine(Mabon);
- //Console.WriteLine(Yule);
- //Console.WriteLine((Yule - Mabon).TotalDays);
- int winter = Vernal.DayOfYear - 1;
- int spring = (int)(Midsummer - Vernal).TotalDays;
- int summer = (int)(Mabon - Midsummer).TotalDays;
- int fall = (int)(Yule - Mabon).TotalDays;
- //Console.WriteLine("days in fall");
- //Console.WriteLine(fall);
- if (Gregory == true)
- {
- fall -= 9;
- }
- DateTime newyeareve = new DateTime(year, 12, 31);
- int intercalary = (int)(newyeareve - Yule).TotalDays;
- //Console.WriteLine("Winter " + winter + " spring " + spring + " summer " + summer + " fall " + fall + " intercalary " + intercalary);
- // other important numbers
- //int preEaster = (int)(Easter - Vernal).TotalDays;
- //int preHannukkah = (int)(HannukahBeginning - Mabon).TotalDays;
- //int preThanksgiving = (int)(Thanksgiving - Mabon).TotalDays;
- int Cap = 0;
- int Aqua = 0;
- int Pis = 0;
- int Ari = 0;
- int Tau = 0;
- int Gem = 0;
- int Can = 0;
- int Leo = 0;
- int Vir = 0;
- int Lib = 0;
- int Sco = 0;
- int Sag = 0;
- int Manu = 0;
- //days short in season are taken from first month
- //extra days in a season are put in the last month
- int wintersmudge = winter - 90;
- if (wintersmudge < 0)
- {
- Cap = wintersmudge;
- }
- else
- {
- Pis = wintersmudge;
- }
- int springsmudge = spring - 90;
- if (springsmudge < 0)
- {
- Ari = springsmudge;
- }
- else
- {
- Gem = springsmudge;
- }
- int summersmudge = summer - 90;
- if (summersmudge < 0)
- {
- Can = summersmudge;
- }
- else
- {
- Vir = summersmudge;
- }
- int fallsmudge = fall - 90;
- if (fallsmudge < 0)
- {
- Lib = fallsmudge;
- }
- else
- {
- Sag = fallsmudge;
- }
- Cap += 30;
- Aqua = 30;
- Pis += 30;
- Ari += 30;
- Tau = 30;
- Gem += 30;
- Can += 30;
- Leo = 30;
- Vir += 30;
- Lib += 30;
- Sco = 30;
- Sag += 30;
- Manu = intercalary;
- //Console.WriteLine("Cap");
- //Console.WriteLine(Cap);
- //Console.WriteLine("Aqua");
- //Console.WriteLine(Aqua);
- //Console.WriteLine("Pis");
- //Console.WriteLine(Pis);
- //Console.WriteLine("Ari");
- //Console.WriteLine(Ari);
- //Console.WriteLine("Tau");
- //Console.WriteLine(Tau);
- //Console.WriteLine("Gem");
- //Console.WriteLine(Gem);
- //Console.WriteLine("Can");
- //Console.WriteLine(Can);
- //Console.WriteLine("Leo");
- //Console.WriteLine(Leo);
- //Console.WriteLine("Vir");
- //Console.WriteLine(Vir);
- //Console.WriteLine("Lib");
- //Console.WriteLine(Lib);
- //Console.WriteLine("Sco");
- //Console.WriteLine(Sco);
- //Console.WriteLine("Sag");
- //Console.WriteLine(Sag);
- //Console.WriteLine("Manu");
- //Console.WriteLine(Manu);
- int yeardays;
- yeardays = newyeareve.DayOfYear;
- //Console.WriteLine("how many days in the year");
- //Console.WriteLine(yeardays);
- //yeardays = Cap + Aqua + Pis + Ari + Tau + Gem + Can + Leo + Vir + Lib + Sco + Sag + Manu;
- if (Gregory == true)
- {
- //Console.WriteLine("1582 yeardays calculated");
- //Console.WriteLine(yeardays);
- yeardays = 355;
- }
- int holidays = 1 + (spring % 30) + (summer % 30) + (fall % 30) + Manu;
- //Console.WriteLine(Cap);
- //Console.WriteLine(Aqua);
- //Console.WriteLine(Pis);
- //Console.WriteLine(Ari);
- //Console.WriteLine(Tau);
- //Console.WriteLine(Gem);
- //Console.WriteLine(Can);
- //Console.WriteLine(Leo);
- //Console.WriteLine(Vir);
- //Console.WriteLine(Lib);
- //Console.WriteLine(Sco);
- //Console.WriteLine(Sag);
- //Console.WriteLine(Manu);
- //Console.WriteLine(yeardays);
- //Console.WriteLine(holidays);
- MannicDay[] MannicYear = new MannicDay[yeardays];
- int i = 0;
- int month = 1;
- int day = 1;
- string feast = "none";
- int monthdays = Cap;
- //filling the array with days
- DateTime Gregorian = new DateTime(year, 1, 1);
- while (i < yeardays)
- {
- //getting inputs
- //public MannicDay (DateTime Gregorian, int dayoftheyear, int year, int month, int day)
- int dayoftheyear = i + 1;
- //Gregorian Calendar dependent dates
- if ((Gregorian.Month == 12) && (Gregorian.Day == 25))
- {
- feast = "Gregorian Christmas";
- }
- //Mannic feasts/Holidays
- if (month == 13)
- {
- switch (day)
- {
- case 1:
- feast = "1st Blessing of Manu";
- break;
- case 2:
- feast = "2nd Blessing of Manu";
- break;
- case 3:
- feast = "3rd Blessing of Manu";
- break;
- case 5:
- feast = "Christmas of Manu";
- break;
- default:
- feast = (day + "th Blessing of Manu");
- break;
- }
- }
- if (day == 1)
- {
- switch (month)
- {
- case 1:
- feast = "Feast of Capricorn"; break;
- case 2:
- feast = "Feast of Aquarius"; break;
- case 3:
- feast = "Feast of Pisces"; break;
- case 4:
- feast = "Feast of Aries"; break;
- case 5:
- feast = "Feast of Taurus"; break;
- case 6:
- feast = "Feast of Gemini"; break;
- case 7:
- feast = "Feast of Cancer"; break;
- case 8:
- feast = "Feast of Leo"; break;
- case 9:
- feast = "Feast of Virgo"; break;
- case 10:
- feast = "Feast of Libra"; break;
- case 11:
- feast = "Feast of Scorpio"; break;
- case 12:
- feast = "Feast of Saggittarius"; break;
- case 13:
- feast = "Feast of Manu"; break;
- }
- }
- if ((monthdays < 30) && (day == monthdays) && (month < 13))
- {
- feast = "Sabbath of Doors";
- }
- if (Gregorian == newyeareve)
- {
- feast = "Feast of Yemo";
- }
- if (day > 30)
- {
- int ordinal = day - 30;
- string monthname = "Capricorn";
- switch (month)
- {
- case 1:
- monthname = "Capricorn"; break;
- case 2:
- monthname = "Aquarius"; break;
- case 3:
- monthname = "Pisces"; break;
- case 4:
- monthname = "Aries"; break;
- case 5:
- monthname = "Taurus"; break;
- case 6:
- monthname = "Gemini"; break;
- case 7:
- monthname = "Cancer"; break;
- case 8:
- monthname = "Leo"; break;
- case 9:
- monthname = "Virgo"; break;
- case 10:
- monthname = "Libra"; break;
- case 11:
- monthname = "Scorpio"; break;
- case 12:
- monthname = "Saggittarius"; break;
- case 13:
- monthname = "Mannus"; break;
- }
- switch (ordinal)
- {
- case 1:
- feast = ("1st Blessing of " + monthname);
- break;
- case 2:
- feast = ("2nd Blessing of " + monthname);
- break;
- case 3:
- feast = ("3rd Blessing of " + monthname);
- break;
- default:
- feast = (ordinal + "th Blessing of " + monthname);
- break;
- }
- }
- if ((month == 12) && (day == monthdays))
- {
- feast = "Eve of the Solstice";
- }
- //initialize object
- MannicYear[i] = new MannicDay(Gregorian, dayoftheyear, year, month, day, feast);
- //Console.WriteLine(MannicYear[i].ToString());
- //move calendar forward
- day++;
- if (month == 13)
- {
- }
- else if (monthdays < day)
- {
- day = 1;
- month++;
- switch (month)
- {
- case 1:
- monthdays = Cap; break;
- case 2:
- monthdays = Aqua; break;
- case 3:
- monthdays = Pis; break;
- case 4:
- monthdays = Ari; break;
- case 5:
- monthdays = Tau; break;
- case 6:
- monthdays = Gem; break;
- case 7:
- monthdays = Can; break;
- case 8:
- monthdays = Leo; break;
- case 9:
- monthdays = Vir; break;
- case 10:
- monthdays = Lib; break;
- case 11:
- monthdays = Sco; break;
- case 12:
- monthdays = Sag; break;
- case 13:
- monthdays = Manu; break;
- }
- }
- //reset variables
- if ((Gregory == true) && (Gregorian == LastJulian))
- {
- Gregorian = FirstGregorian;
- }
- else { Gregorian = Gregorian.AddDays(1); }
- feast = "none";
- i++;
- }
- //returning date
- return MannicYear[day_of_the_year_to_convert];
- /*
- int i = 0;
- int month = 1;
- int day = 1;
- string feast = "none";
- */
- }
- public static DateTime CalculateDate(double val, int calendar, int date)
- {
- double ut;
- int jdn;
- int year;
- int month;
- int day;
- int hour;
- int minute;
- bool julian;
- int x;
- int z;
- int m;
- int d;
- int y;
- int daysPer400Years = 146097;
- int fudgedDaysPer4000Years = 1460970 + 31;
- val += 0.5; // Convert astronomical JDN to chronological
- jdn = (int)Math.Floor(val);
- ut = val - jdn;
- //julian = (jdn <= DefineConstants.LASTJULJDN);
- switch (calendar)
- {
- case 1: //gregorian
- julian = false;
- break;
- case 2: //julian
- julian = true;
- break;
- // possibly add more calendars as we go along, converting them to Gregorian first and then to Mannic
- case 3: //British Old Style Calendar
- //break;
- case 4: //Swedish
- //break;
- default: //julian gregorian unknown
- if (date <= 1582)
- {
- julian = true;
- }
- else
- {
- julian = false;
- }
- break;
- }
- x = jdn + 68569;
- if (julian == true)
- {
- x += 38;
- daysPer400Years = 146100;
- fudgedDaysPer4000Years = 1461000 + 1;
- }
- z = 4 * x / daysPer400Years;
- x = x - (daysPer400Years * z + 3) / 4;
- y = 4000 * (x + 1) / fudgedDaysPer4000Years;
- x = x - 1461 * y / 4 + 31;
- m = 80 * x / 2447;
- d = x - 2447 * m / 80;
- x = m / 11;
- m = m + 2 - 12 * x;
- y = 100 * (z - 49) + y + x;
- year = (int)y;
- month = (int)m;
- day = (int)d;
- if (year <= 0) // adjust BC years
- {
- year--;
- }
- hour = (int)(ut * 24);
- minute = (int)((ut * 24 - hour) * 60); // Accurate to about 15 minutes c. 2000 CE.
- //retval.Format("%02d-%02d-%4d %02d:%02d GMT", day, month, year, hour, minute);
- DateTime retval = new DateTime(year, month, day, hour, minute, 0);
- return (retval);
- }
- public static DateTime[] Points(int input_year, int calendar)
- {
- DateTime[] points = new DateTime[4];
- double m;
- double ve;
- double ss;
- double ae;
- double ws;
- m = ((double)input_year - 2000.0) / 1000.0;
- ve = 2451623.80984 + 365242.37404 * m + 0.05169 * m * m - 0.00411 * m * m * m - 0.00057 * m * m * m * m;
- points[0] = CalculateDate(ve, calendar, input_year);
- ss = 2451716.56767 + 365241.62603 * m + 0.00325 * m * m + 0.00888 * m * m * m - 0.00030 * m * m * m * m;
- points[1] = CalculateDate(ss, calendar, input_year);
- ae = 2451810.21715 + 365242.01767 * m - 0.11575 * m * m + 0.00337 * m * m * m + 0.00078 * m * m * m * m;
- points[2] = CalculateDate(ae, calendar, input_year);
- ws = 2451900.05952 + 365242.74049 * m - 0.06223 * m * m - 0.00823 * m * m * m + 0.00032 * m * m * m * m;
- points[3] = CalculateDate(ws, calendar, input_year);
- return points;
- }
- public static string textform(int input)
- {
- string suffix;
- int end = input % 100;
- int ten = 10;
- if ((end / ten) == 1)
- {
- suffix = "th";
- }
- else
- {
- end %= 10;
- switch (end)
- {
- case 1:
- suffix = "st";
- break;
- case 2:
- suffix = "nd";
- break;
- case 3:
- suffix = "rd";
- break;
- default:
- suffix = "th";
- break;
- }
- }
- return (input + suffix);
- }
- }
- class MannicDay
- {
- public DateTime Gregorian;
- public int dayoftheyear;
- public int year;
- public int month;
- public int day;
- public string feast;
- public MannicDay(DateTime Gregorian, int dayoftheyear, int year, int month, int day, string feast)
- {
- this.Gregorian = Gregorian;
- this.dayoftheyear = dayoftheyear;
- if (year >= 1)
- {
- this.year = year + 10000;
- }
- else
- {
- this.year = year + 1001;
- }
- this.month = month;
- this.day = day;
- this.feast = feast;
- }
- public string getmonthname()
- {
- switch (this.month)
- {
- case 1:
- return "Capricorn";
- case 2:
- return "Aquarius";
- case 3:
- return "Pisces";
- case 4:
- return "Aries";
- case 5:
- return "Taurus";
- case 6:
- return "Gemini";
- case 7:
- return "Cancer";
- case 8:
- return "Leo";
- case 9:
- return "Virgo";
- case 10:
- return "Libra";
- case 11:
- return "Scorpio";
- case 12:
- return "Saggittarius";
- case 13:
- return "Mannus";
- }
- return "?";
- }
- public string monthabbreviation()
- {
- switch (this.month)
- {
- case 1:
- return "Cap";
- case 2:
- return "Aqua";
- case 3:
- return "Pis";
- case 4:
- return "Ari";
- case 5:
- return "Tau";
- case 6:
- return "Gem";
- case 7:
- return "Can";
- case 8:
- return "Leo";
- case 9:
- return "Vir";
- case 10:
- return "Lib";
- case 11:
- return "Sco";
- case 12:
- return "Sag";
- case 13:
- return "Manu";
- }
- return "?";
- }
- public string getmonthsymbol()
- {
- switch (this.month)
- {
- case 1:
- return "♑";
- case 2:
- return "♒";
- case 3:
- return "♓️";
- case 4:
- return "♈";
- case 5:
- return "♉";
- case 6:
- return "♊";
- case 7:
- return "♋️";
- case 8:
- return "♌";
- case 9:
- return "♍";
- case 10:
- return "♎";
- case 11:
- return "♏";
- case 12:
- return "♐";
- case 13:
- return "🎄";
- }
- return "?";
- }
- public string getfeast()
- {
- return this.feast;
- }
- public bool feastbool()
- {
- if (string.Equals(this.feast, "none") == true)
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- public bool dayoff()
- {
- if (this.feastbool() == true)
- {
- return true;
- }
- if ((this.day % 5) == 1)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public DateTime getGregorian()
- {
- return this.Gregorian;
- }
- public int getmonth()
- {
- return this.month;
- }
- public int getyear()
- {
- return this.year;
- }
- public int getday()
- {
- return this.day;
- }
- public int getdayoftheyear()
- {
- return this.dayoftheyear;
- }
- public string ymd()
- {
- //return string("" + this.year + "/" + this.month + "/" + this.day);
- string output = ("" + this.year + "/" + this.month + "/" + this.day);
- return output;
- }
- public string dmy()
- {
- string output = ("" + this.day + "/" + this.month + "/" + this.year);
- return output;
- }
- public string mdy()
- {
- string output = ("" + this.month + "/" + this.day + "/" + this.year);
- return output;
- }
- public string weekday()
- {
- switch (this.day % 5)
- {
- case 1:
- return "Adonai";
- case 2:
- return "Mithra";
- case 3:
- return "Azoth";
- case 4:
- return "Oxa";
- default:
- return "Manu";
- }
- }
- override public string ToString()
- {
- string s0 = ("" + this.getdayoftheyear());
- string s1 = this.ymd();
- string s2 = this.getmonthsymbol();
- string s3 = this.getmonthname();
- string s4 = this.feast;
- string greg = this.Gregorian.ToString();
- string text = ("day " + s0 + " " + greg + " " + s1 + " " + s3 + " " + s4);
- return text;
- }
- public string display()
- {
- string weekday = this.weekday();
- int day = this.getday();
- string dayth = textform(day);
- string month = this.getmonthname();
- int year = this.getyear();
- string yearth = textform(year);
- string display = (weekday + "day " + month + " " + dayth + ", of the " + yearth + " year of Manu");
- return display;
- }
- public static string textform(int input)
- {
- string suffix;
- int end = input % 100;
- int ten = 10;
- if ((end / ten) == 1)
- {
- suffix = "th";
- }
- else
- {
- end %= 10;
- switch (end)
- {
- case 1:
- suffix = "st";
- break;
- case 2:
- suffix = "nd";
- break;
- case 3:
- suffix = "rd";
- break;
- default:
- suffix = "th";
- break;
- }
- }
- return (input + suffix);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement