private int CalculateNaksatras(GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCEarthData earth, GCConfigRatedEvents rec) { int nData = 0; GregorianDateTime vcNext; int ndst; bool prevNaksatraValid = false; GregorianDateTime prevNaksatra = new GregorianDateTime(); vcAdd.SubtractDays(1); while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { vcNext.InitWeekDay(); vcNext.AddHours(loc.TimeZone.GetBiasMinutesForDay(vcNext) / 60.0); //AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData, ndst); AddRating(vcNext, rec.rateNaksatra[nData], rec.rateNaksatra[Prev(nData, 27)]); if (prevNaksatraValid) { double padaLength = (vcNext.GetJulianComplete() - prevNaksatra.GetJulianComplete()) / 4.0; for (int j = 0; j < 4; j++) { //AddEvent(prevNaksatra, CoreEventType.CCTYPE_NAKS_PADA1 + j, nData, ndst); int prevPada = (nData * 4 + j + 107) % 108; AddRating(vcNext, rec.rateNaksatraPada[nData, j], rec.rateNaksatraPada[prevPada / 4, prevPada % 4]); prevNaksatra.shour += padaLength; prevNaksatra.NormalizeValues(); } } prevNaksatra.Set(vcNext); prevNaksatraValid = true; } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.2; if (vcAdd.shour >= 1.0) { vcAdd.shour -= 1.0; vcAdd.NextDay(); } } return(nData); }
public override GSCore GetPropertyValue(string s) { switch (s) { case "nType": return(new GSNumber(nType)); case "nData": return(new GSNumber(nType)); case "Time": return(Time); case "nDst": return(new GSNumber(nDst)); case "tithiName": return(new GSString(GCTithi.GetName(nData))); case "naksatraName": return(new GSString(GCNaksatra.GetName(nData))); case "rasiName": return(new GSString(GCRasi.GetName(nData))); case "groupNameString": return(new GSString(GetTypeString(nType))); case "typeString": return(new GSString(GetTypeString(nType, nData))); case "dstSignature": return(new GSString(GCStrings.GetDSTSignature(nDst))); default: return(base.GetPropertyValue(s)); } }
public void CalculateEvents(GCLocation loc, int nYear) { //GCSunData sun = new GCSunData(); //DstTypeChange ndst = DstTypeChange.DstOff; int nData; TResultCoreEvents inEvents = this; this.Clear(); this.EarthLocation = loc; this.Year = nYear; GregorianDateTime vcStart = new GregorianDateTime(Year - 1, 12, 29); GregorianDateTime vcEnd = new GregorianDateTime(Year + 1, 1, 2); GregorianDateTime vc = new GregorianDateTime(); GregorianDateTime vcAdd = new GregorianDateTime(), vcNext = new GregorianDateTime(); GCEarthData earth = loc.GetEarthData(); vc.Set(vcStart); vc.TimezoneHours = loc.OffsetUtcHours; vcAdd.Set(vc); vcAdd.InitWeekDay(); /*while (vcAdd.IsBeforeThis(vcEnd)) * { * ndst = loc.TimeZone.DetermineDaylightChange(vcAdd); * vcAdd.NextDay(); * }*/ if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_TITHI) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { //vcNext.InitWeekDay(); //ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData); } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.2; if (vcAdd.shour >= 1.0) { vcAdd.shour -= 1.0; vcAdd.NextDay(); } } } if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_NAKSATRA) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { //vcNext.InitWeekDay(); //ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData); } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.2; if (vcAdd.shour >= 1.0) { vcAdd.shour -= 1.0; vcAdd.NextDay(); } } } if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YOGA) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { //vcNext.InitWeekDay(); //ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData); } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.2; if (vcAdd.shour >= 1.0) { vcAdd.shour -= 1.0; vcAdd.NextDay(); } } } if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SANKRANTI) != 0) { vcNext = new GregorianDateTime(); vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData)); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { //vcNext.InitWeekDay(); //ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData); } else { break; } vcAdd.Set(vcNext); vcAdd.NextDay(); } } if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOONRASI) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCMoonData.GetNextMoonRasi(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { //vcNext.InitWeekDay(); //ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RASI, nData); } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.5; vcAdd.NormalizeValues(); } } if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_CONJUNCTION) != 0) { double dlong; vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { dlong = GCConjunction.GetNextConjunction(vcAdd, out vcNext, true, earth); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { vcNext.InitWeekDay(); //ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_CONJ, GCRasi.GetRasi(dlong, GCAyanamsha.GetAyanamsa(vcNext.GetJulianComplete()))); } else { break; } vcAdd.Set(vcNext); vcAdd.NextDay(); } } inEvents.Sort(); }
public string Format(string format, params string[] args) { StringBuilder sb = new StringBuilder(format); if (format.IndexOf("{day}") >= 0) { format = format.Replace("{day}", date.day.ToString()); } if (format.IndexOf("{month}") >= 0) { format = format.Replace("{month}", date.month.ToString()); } if (format.IndexOf("{monthAbr}") >= 0) { format = format.Replace("{monthAbr}", GregorianDateTime.GetMonthName(date.month)); } if (format.IndexOf("{monthName}") >= 0) { format = format.Replace("{monthName}", GregorianDateTime.GetMonthName(date.month)); } if (format.IndexOf("{year}") >= 0) { format = format.Replace("{year}", date.year.ToString()); } if (format.IndexOf("{hour}") >= 0) { format = format.Replace("{hour}", date.GetHour().ToString("D2")); } if (format.IndexOf("{min}") >= 0) { format = format.Replace("{min}", date.GetMinute().ToString("D2")); } if (format.IndexOf("{minRound}") >= 0) { format = format.Replace("{minRound}", date.GetMinuteRound().ToString("D2")); } if (format.IndexOf("{sec}") >= 0) { format = format.Replace("{sec}", date.GetSecond().ToString("D2")); } if (format.IndexOf("{masaName}") >= 0) { format = format.Replace("{masaName}", GCMasa.GetName(astrodata.Masa)); } if (format.IndexOf("{gaurabdaYear}") >= 0) { format = format.Replace("{gaurabdaYear}", astrodata.GaurabdaYear.ToString()); } if (format.IndexOf("{tithiName}") >= 0) { format = format.Replace("{tithiName}", GCTithi.GetName(astrodata.sunRise.Tithi)); } if (format.IndexOf("{prevTithiName}") >= 0) { format = format.Replace("{prevTithiName}", GCTithi.GetName((astrodata.sunRise.Tithi + 29) % 30)); } if (format.IndexOf("{nextTithiName}") >= 0) { format = format.Replace("{nextTithiName}", GCTithi.GetName((astrodata.sunRise.Tithi + 1) % 30)); } if (format.IndexOf("{paksaName}") >= 0) { format = format.Replace("{paksaName}", GCPaksa.GetName(astrodata.sunRise.Paksa)); } if (format.IndexOf("{yogaName}") >= 0) { format = format.Replace("{yogaName}", GCYoga.GetName(astrodata.sunRise.Yoga)); } if (format.IndexOf("{naksatraName}") >= 0) { format = format.Replace("{naksatraName}", GCNaksatra.GetName(astrodata.sunRise.Naksatra)); } if (format.IndexOf("{naksatraElapse}") >= 0) { format = format.Replace("{naksatraElapse}", astrodata.sunRise.NaksatraElapse.ToString("P2")); } if (format.IndexOf("{naksatraPada}") >= 0) { format = format.Replace("{naksatraPada}", GCNaksatra.GetPadaText(astrodata.sunRise.NaksatraPada)); } if (format.IndexOf("{sankranti.day}") >= 0) { format = format.Replace("{sankranti.day}", sankranti_day.day.ToString()); } if (format.IndexOf("{sankranti.month}") >= 0) { format = format.Replace("{sankranti.month}", sankranti_day.month.ToString()); } if (format.IndexOf("{sankranti.monthAbr}") >= 0) { format = format.Replace("{sankranti.monthAbr}", GregorianDateTime.GetMonthName(sankranti_day.month)); } if (format.IndexOf("{sankranti.monthName}") >= 0) { format = format.Replace("{sankranti.monthName}", GregorianDateTime.GetMonthName(sankranti_day.month)); } if (format.IndexOf("{sankranti.hour}") >= 0) { format = format.Replace("{sankranti.hour}", sankranti_day.GetHour().ToString("D2")); } if (format.IndexOf("{sankranti.min}") >= 0) { format = format.Replace("{sankranti.min}", sankranti_day.GetMinute().ToString("D2")); } if (format.IndexOf("{sankranti.minRound}") >= 0) { format = format.Replace("{sankranti.minRound}", sankranti_day.GetMinuteRound().ToString("D2")); } if (format.IndexOf("{sankranti.sec}") >= 0) { format = format.Replace("{sankranti.sec}", sankranti_day.GetSecond().ToString("D2")); } if (format.IndexOf("{sankranti.rasiNameEn}") >= 0) { format = format.Replace("{sankranti.rasiNameEn}", GCRasi.GetNameEn(sankranti_zodiac)); } if (format.IndexOf("{sankranti.rasiName}") >= 0) { format = format.Replace("{sankranti.rasiName}", GCRasi.GetName(sankranti_zodiac)); } if (format.IndexOf("{dstSig}") >= 0) { format = format.Replace("{dstSig}", GCStrings.GetDSTSignature(BiasMinutes)); } if (format.IndexOf("{moonRiseTime}") >= 0) { format = format.Replace("{moonRiseTime}", moonrise.ToShortTimeString()); } if (format.IndexOf("{moonSetTime}") >= 0) { format = format.Replace("{moonSetTime}", moonset.ToShortTimeString()); } if (format.IndexOf("{moonRasiName}") >= 0) { format = format.Replace("{moonRasiName}", GCRasi.GetName(astrodata.sunRise.RasiOfMoon)); } if (format.IndexOf("{moonRasiNameEn}") >= 0) { format = format.Replace("{moonRasiNameEn}", GCRasi.GetNameEn(astrodata.sunRise.RasiOfMoon)); } if (args == null || args.Length == 0) { return(format.ToString()); } else { return(string.Format(format.ToString(), args)); } }
public static string GetTypeString(int nType, int nData) { switch (nType) { case CoreEventType.CCTYPE_ASCENDENT: return("Ascendent " + GCRasi.GetName(nData)); case CoreEventType.CCTYPE_CONJ: return("Conjunction in " + GCRasi.GetName(nData)); case CoreEventType.CCTYPE_DATE: return("Date"); case CoreEventType.CCTYPE_DAY_MUHURTA: return(string.Format("{0} Muhurta", GCStrings.GetMuhurtaName(nData))); case CoreEventType.CCTYPE_DAY_OF_WEEK: return(GCCalendar.GetWeekdayName(nData)); case CoreEventType.CCTYPE_KALA_END: return(string.Format("{0} ends", GCStrings.GetKalaName(nData))); case CoreEventType.CCTYPE_KALA_START: return(string.Format("{0} starts", GCStrings.GetKalaName(nData))); case CoreEventType.CCTYPE_M_RASI: return(string.Format("Moon in {0} rasi", GCRasi.GetName(nData))); case CoreEventType.CCTYPE_M_RISE: return("Moon rise"); case CoreEventType.CCTYPE_M_SET: return("Moon set"); case CoreEventType.CCTYPE_NAKS: return(string.Format("{0} Naksatra", GCNaksatra.GetName(nData))); case CoreEventType.CCTYPE_S_ARUN: return("Arunodaya"); case CoreEventType.CCTYPE_S_MIDNIGHT: return("Midnight"); case CoreEventType.CCTYPE_S_NOON: return("Noon"); case CoreEventType.CCTYPE_S_RISE: return("Sunrise"); case CoreEventType.CCTYPE_S_SET: return("Sunset"); case CoreEventType.CCTYPE_SANK: return(string.Format("{0} Sankranti", GCRasi.GetName(nData))); case CoreEventType.CCTYPE_TITHI: return(string.Format("{0} Tithi", GCTithi.GetName(nData))); case CoreEventType.CCTYPE_YOGA: return(string.Format("{0} Yoga", GCYoga.GetName(nData))); default: return(string.Format("Unspecified event {0} / {1}", nType, nData)); } }
public void CalculateEvents(GCLocation loc, GregorianDateTime vcStart, GregorianDateTime vcEnd) { //GCSunData sun = new GCSunData(); DstTypeChange ndst = 0; int nData; TResultEvents inEvents = this; this.Clear(); this.EarthLocation = loc; this.StartDateTime = new GregorianDateTime(vcStart); this.EndDateTime = new GregorianDateTime(vcEnd); GregorianDateTime vc = new GregorianDateTime(); GregorianDateTime vcAdd = new GregorianDateTime(), vcNext = new GregorianDateTime(); GCEarthData earth = loc.GetEarthData(); vc.Set(vcStart); vc.TimezoneHours = loc.OffsetUtcHours; vcAdd.Set(vc); vcAdd.InitWeekDay(); GCHourTime sunriseData, sunsetData; double sunRise, sunSet; double r1, r2; while (vcAdd.IsBeforeThis(vcEnd)) { sunriseData = GCSunData.CalcSunrise(vcAdd, earth); sunsetData = GCSunData.CalcSunset(vcAdd, earth); sunRise = sunriseData.TotalDays; sunSet = sunsetData.TotalDays; ndst = loc.TimeZone.DetermineDaylightChange(vcAdd); if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SUN) != 0) { ndst = loc.TimeZone.DetermineDaylightChange(vcAdd); vcAdd.shour = sunriseData.TotalDays - 96.0 / 1440.0; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_ARUN, 0, ndst); vcAdd.shour = sunRise; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_RISE, 0, ndst); vcAdd.shour = (sunRise + sunSet) / 2; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_NOON, 0, ndst); vcAdd.shour = sunSet; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_SET, 0, ndst); } /*if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0) * { * todayLongitude = sun.longitude_deg; * vcAdd.shour = sunRise; * todaySunriseHour = sunRise; * if (previousLongitude < -10) * { * GregorianDateTime prevSunrise = new GregorianDateTime(); * prevSunrise.Set(vcAdd); * prevSunrise.PreviousDay(); * sun.SunCalc(prevSunrise, earth); * previousSunriseHour = sun.rise.GetDayTime() - 1; * previousLongitude = sun.longitude_deg; * fromTimeLimit = 0; * } * * double a, b; * double jd = vcAdd.GetJulianComplete(); * double ayan = GCAyanamsha.GetAyanamsa(jd); * r1 = GCMath.putIn360(previousLongitude - ayan) / 30; * r2 = GCMath.putIn360(todayLongitude - ayan) / 30; * * while (r2 > r1 + 13) * { * r2 -= 12.0; * } * while (r2 < r1 + 11) * { * r2 += 12.0; * } * * a = (r2 - r1) / (todaySunriseHour - previousSunriseHour); * b = r2 - a * todaySunriseHour; * * for (double tr = Math.Floor(r1) + 1.0; tr < r2; tr += 1.0) * { * double tm = (tr - b) / a; * if (tm > fromTimeLimit) * { * vcNext.Set(vcAdd); * vcNext.shour = tm; * vcNext.NormalizeValues(); * inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_ASCENDENT, (int)tr, ndst); * } * } * * previousLongitude = todayLongitude; * previousSunriseHour = todaySunriseHour - 1; * fromTimeLimit = previousSunriseHour; * }*/ if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_RAHUKALAM) != 0) { GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_RAHU_KALAM); vcAdd.shour = r1; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_RAHU_KALAM, ndst); vcAdd.shour = r2; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_RAHU_KALAM, ndst); } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YAMAGHANTI) != 0) { GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_YAMA_GHANTI); vcAdd.shour = r1; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_YAMA_GHANTI, ndst); vcAdd.shour = r2; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_YAMA_GHANTI, ndst); } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_GULIKALAM) != 0) { GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_GULI_KALAM); vcAdd.shour = r1; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_GULI_KALAM, ndst); vcAdd.shour = r2; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_GULI_KALAM, ndst); } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ABHIJIT_MUHURTA) != 0) { GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_ABHIJIT); if (r1 > 0 && r2 > 0) { vcAdd.shour = r1; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_ABHIJIT, ndst); vcAdd.shour = r2; inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_ABHIJIT, ndst); } } vcAdd.NextDay(); } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0) { GCAscendant asc = new GCAscendant(); asc.Earth = EarthLocation.GetEarthData(); asc.CurrentDateTime = new GregorianDateTime(vc); while (asc.GetNextAscendantBefore(vcEnd)) { ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(asc.CurrentDateTime, CoreEventType.CCTYPE_ASCENDENT, asc.CurrentSign, ndst); asc.CurrentDateTime.AddHours(0.5); } } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_TITHI) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { vcNext.InitWeekDay(); ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData, ndst); } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.2; if (vcAdd.shour >= 1.0) { vcAdd.shour -= 1.0; vcAdd.NextDay(); } } } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_NAKSATRA) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { vcNext.InitWeekDay(); ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData, ndst); } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.2; if (vcAdd.shour >= 1.0) { vcAdd.shour -= 1.0; vcAdd.NextDay(); } } } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YOGA) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { vcNext.InitWeekDay(); ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData, ndst); } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.2; if (vcAdd.shour >= 1.0) { vcAdd.shour -= 1.0; vcAdd.NextDay(); } } } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SANKRANTI) != 0) { vcNext = new GregorianDateTime(); vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData)); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { vcNext.InitWeekDay(); ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData, ndst); } else { break; } vcAdd.Set(vcNext); vcAdd.NextDay(); } } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOONRASI) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { nData = GCMoonData.GetNextMoonRasi(earth, vcAdd, out vcNext); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { vcNext.InitWeekDay(); ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RASI, nData, ndst); } else { break; } vcAdd.Set(vcNext); vcAdd.shour += 0.5; vcAdd.NormalizeValues(); } } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_CONJUNCTION) != 0) { double dlong; vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { dlong = GCConjunction.GetNextConjunction(vcAdd, out vcNext, true, earth); if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) { vcNext.InitWeekDay(); ndst = loc.TimeZone.DetermineDaylightChange(vcNext); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_CONJ, GCRasi.GetRasi(dlong, GCAyanamsha.GetAyanamsa(vcNext.GetJulianComplete())), ndst); } else { break; } vcAdd.Set(vcNext); vcAdd.NextDay(); } } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOON) != 0) { vcAdd.Set(vc); vcAdd.shour = 0.0; while (vcAdd.IsBeforeThis(vcEnd)) { vcNext.Set(GCMoonData.GetNextRise(earth, vcAdd, true)); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RISE, 0, ndst); vcNext.Set(GCMoonData.GetNextRise(earth, vcNext, false)); inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_SET, 0, ndst); vcNext.shour += 0.05; vcNext.NormalizeValues(); vcAdd.Set(vcNext); } } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0) {/* * vcAdd = vc; * vcAdd.shour = 0.0; * while(vcAdd.IsBeforeThis(vcEnd)) * { * nData = earth.GetNextAscendentStart(vcAdd, vcNext); * if (vcNext.GetDayInteger() < vcEnd.GetDayInteger()) * { * vcNext.InitWeekDay(); * ndst = TTimeZone.determineDaylightChange(vcNext, loc.m_nDST); * inEvents.AddEvent(vcNext, CCTYPE_ASCENDENT, nData, ndst); * } * else * { * break; * } * vcAdd = vcNext; * vcAdd.shour += 1/24.0; * if (vcAdd.shour >= 1.0) * { * vcAdd.shour -= 1.0; * vcAdd.NextDay(); * } * } * */ } if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SORT) != 0) { inEvents.Sort(SORTING_BY_DATE); } else { inEvents.Sort(SORTING_BY_TYPE); } }
public void calculateAppDay(GCLocation location, GregorianDateTime eventDate) { //MOONDATA moon; //SUNDATA sun; GCAstroData d = this.details = new GCAstroData(); GregorianDateTime vc = new GregorianDateTime(); GregorianDateTime vcsun = new GregorianDateTime(); GCEarthData m_earth = location.GetEarthData(); vc.Set(eventDate); vcsun.Set(eventDate); this.b_adhika = false; this.eventTime = new GregorianDateTime(eventDate); Location = location; //d.nTithi = GetPrevTithiStart(m_earth, vc, dprev); //GetNextTithiStart(m_earth, vc, dnext); vcsun.shour -= vcsun.TimezoneHours / 24.0; vcsun.NormalizeValues(); vcsun.TimezoneHours = 0.0; d.sunRise = new GCHourTime(); d.sunRise.TotalDays = vc.shour; d.sunRise.longitude = GCCoreAstronomy.GetSunLongitude(vcsun, m_earth); d.sunRise.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(vcsun, m_earth); d.Ayanamsa = GCAyanamsha.GetAyanamsa(vc.GetJulianComplete()); d.sunRise.Ayanamsa = d.Ayanamsa; // tithi d.Masa = d.MasaCalc(vc, m_earth); if (d.Masa == (int)MasaId.ADHIKA_MASA) { d.Masa = d.sunRise.RasiOfSun; this.b_adhika = true; } vc.Today(); vc.TimezoneHours = m_earth.OffsetUtcHours; int m = 0; GaurabdaDate va = new GaurabdaDate(); GregorianDateTime vctemp; va.tithi = d.sunRise.Tithi; va.masa = d.Masa; va.gyear = GCCalendar.GetGaurabdaYear(vc, m_earth); if (va.gyear < d.GaurabdaYear) { va.gyear = d.GaurabdaYear; } MainInfo.Add(new AppDayInfo(GCStrings.getString(7), eventDate.ToString())); MainInfo.Add(new AppDayBase()); MainInfo.Add(new AppDayInfo(GCStrings.getString(8), eventDate.ShortTimeString())); MainInfo.Add(new AppDayBase()); MainInfo.Add(new AppDayBase()); MainInfo.Add(new AppDayInfo(GCStrings.getString(9), location.Title)); MainInfo.Add(new AppDayInfo(GCStrings.getString(10), location.GetLatitudeString())); MainInfo.Add(new AppDayInfo(GCStrings.getString(11), location.GetLongitudeString())); MainInfo.Add(new AppDayInfo(GCStrings.Localized("Timezone"), location.TimeZoneName)); MainInfo.Add(new AppDayInfo("DST", "N/A")); MainInfo.Add(new AppDayBase()); MainInfo.Add(new AppDayInfo(GCStrings.getString(13), GCTithi.GetName(d.sunRise.Tithi))); MainInfo.Add(new AppDayInfo(GCStrings.getString(14), string.Format("{0:00.000}%", d.sunRise.TithiElapse))); MainInfo.Add(new AppDayInfo(GCStrings.getString(15), GCNaksatra.GetName(d.sunRise.Naksatra))); MainInfo.Add(new AppDayInfo(GCStrings.getString(16), string.Format("{0:00.000}% ({1} pada)", d.sunRise.NaksatraElapse, GCStrings.getString(811 + d.sunRise.NaksatraPada)))); MainInfo.Add(new AppDayInfo(GCStrings.Localized("Moon Rasi"), GCRasi.GetName(d.sunRise.RasiOfMoon))); MainInfo.Add(new AppDayInfo(GCStrings.Localized("Sun Rasi"), GCRasi.GetName(d.sunRise.RasiOfSun))); MainInfo.Add(new AppDayInfo(GCStrings.getString(20), GCPaksa.GetName(d.sunRise.Paksa))); if (b_adhika == true) { MainInfo.Add(new AppDayInfo(GCStrings.getString(22), string.Format("{0} {1}", GCMasa.GetName(d.Masa), GCStrings.getString(21)))); } else { MainInfo.Add(new AppDayInfo(GCStrings.getString(22), GCMasa.GetName(d.Masa))); } MainInfo.Add(new AppDayInfo(GCStrings.getString(23), d.GaurabdaYear.ToString())); if (GCDisplaySettings.Current.getValue(48) == 1) { MainInfo.Add(new AppDayBase(GCDS.APP_CHILDNAMES)); MainInfo.Add(new AppDaySeparator(GCStrings.getString(17))); MainInfo.Add(new AppDayBase(GCDS.APP_CHILDNAMES)); MainInfo.Add(new AppDayInfo(GCDS.APP_CHILDNAMES, GCStrings.getString(18), GCStrings.GetNaksatraChildSylable(d.sunRise.Naksatra, d.sunRise.NaksatraPada) + "...")); MainInfo.Add(new AppDayInfo(GCDS.APP_CHILDNAMES, GCStrings.getString(19), GCStrings.GetRasiChildSylable(d.sunRise.RasiOfMoon) + "...")); } MainInfo.Add(new AppDayBase()); MainInfo.Add(new AppDaySeparator(GCStrings.getString(24))); MainInfo.Add(new AppDayBase()); celeb_date = new GregorianDateTime[TRESULT_APP_CELEBS]; celeb_gy = new int[TRESULT_APP_CELEBS]; for (int i = 0; i < TRESULT_APP_CELEBS + 3; i++) { GCCalendar.VATIMEtoVCTIME(va, out vctemp, m_earth); if (va.gyear > d.GaurabdaYear) { if (m < TRESULT_APP_CELEBS) { MainInfo.Add(new AppDayInfo(string.Format("Gaurabda {0}", va.gyear), vctemp.ToString())); this.celeb_date[m] = new GregorianDateTime(vctemp); this.celeb_gy[m] = va.gyear; m++; } } va.gyear++; } }
public GCConfigRatedEvents() { int i; for (i = 0; i < 30; i++) { rateTithi[i] = new GCConfigRatedEntry(); rateTithi[i].Title = string.Format("{0} Tithi", GCTithi.GetName(i)); rateTithi[i].Key = "Tithi"; rateMuhurta[i] = new GCConfigRatedEntry(); rateMuhurta[i].Title = GCStrings.GetMuhurtaName(i); rateMuhurta[i].Key = "Muhurta"; } for (i = 0; i < 4; i++) { rateDayHours[i] = new GCConfigRatedEntry(); rateDayHours[i].Title = GCStrings.GetSandhyaName(i); rateDayHours[i].Key = "DayHours"; } for (i = 0; i < 2; i++) { rateDay[i] = new GCConfigRatedEntry(); rateDay[i].Title = GCStrings.GetSandhyaName(i * 2); rateDay[i].Key = "DayPart"; rateMoonTime[i] = new GCConfigRatedEntry(); rateMoonTime[i].Title = GCStrings.GetMoonTimesName(i); rateMoonTime[i].Key = "MoonTimes"; } rateKalas[0] = new GCConfigRatedEntry(); for (i = 1; i < 6; i++) { rateKalas[i] = new GCConfigRatedEntry(); rateKalas[i].Title = GCStrings.GetKalaName(i); rateKalas[i].Key = string.Format("kala.{0}", i); } for (i = 0; i < 27; i++) { rateNaksatra[i] = new GCConfigRatedEntry(); rateNaksatra[i].Title = string.Format("{0} Naksatra", GCNaksatra.GetName(i)); rateNaksatra[i].Key = "Naksatra"; rateYoga[i] = new GCConfigRatedEntry(); rateYoga[i].Title = string.Format("{0} Yoga", GCYoga.GetName(i)); rateYoga[i].Key = "Yoga"; for (int j = 0; j < 4; j++) { rateNaksatraPada[i, j] = new GCConfigRatedEntry(); rateNaksatraPada[i, j].Title = string.Format("{0} of {1}", GCNaksatra.GetPadaText(j), rateNaksatra[i].Title); rateNaksatraPada[i, j].Key = "NaksatraPada"; } } for (i = 0; i < 7; i++) { weekday[i] = new GCConfigRatedEntry(); weekday[i].Title = string.Format("Weekday: {0}", GCCalendar.GetWeekdayName(i)); weekday[i].Key = "Weekday"; } for (i = 0; i < 10; i++) { for (int j = 0; j < 12; j++) { rateGrahaRasi[i, j] = new GCConfigRatedEntry(); rateGrahaRasi[i, j].Title = string.Format("{0} in {1}", GCStrings.GetPlanetNameEn(i), GCRasi.GetNameEn(j)); rateGrahaRasi[i, j].Key = "RasiGraha." + GCStrings.GetPlanetNameEn(i); rateGrahaHouse[i, j] = new GCConfigRatedEntry(); rateGrahaHouse[i, j].Title = string.Format("{0} in house {1}", GCStrings.GetPlanetNameEn(i), j + 1); rateGrahaHouse[i, j].Key = "HouseGraha." + GCStrings.GetPlanetNameEn(i); rateRasiGraha[j, i] = rateGrahaRasi[i, j]; rateHouseGraha[j, i] = rateGrahaHouse[i, j]; } } FileName = null; }
public static int writeXml(string fileName, GCLocation loc, GregorianDateTime vc, int nDaysCount) { using (StreamWriter xml = new StreamWriter(fileName)) { xml.Write("<xml>\n"); xml.Write("\t<request name=\"Naksatra\" version=\""); xml.Write(GCStrings.getString(130)); xml.Write("\">\n"); xml.Write("\t\t<arg name=\"longitude\" val=\""); xml.Write(loc.Longitude); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"latitude\" val=\""); xml.Write(loc.Latitude); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"timezone\" val=\""); xml.Write(loc.OffsetUtcHours); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"startdate\" val=\""); xml.Write(vc); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"daycount\" val=\""); xml.Write(nDaysCount); xml.Write("\" />\n"); xml.Write("\t</request>\n"); xml.Write("\t<result name=\"Naksatra\">\n"); GregorianDateTime d = new GregorianDateTime(); d.Set(vc); d.TimezoneHours = loc.OffsetUtcHours; GregorianDateTime dn; GCHourTime dt = new GCHourTime(); int nak; GCEarthData earth = loc.GetEarthData(); for (int i = 0; i < 30; i++) { nak = GCNaksatra.GetNextNaksatra(earth, d, out dn); d.Set(dn); xml.Write("\t\t<day date=\""); xml.Write(d); xml.Write("\">\n"); //str.Format("%d.%d.%d", d.day, d.month, d.year); //n = m_list.InsertItem(50, GetNaksatraName(nak)); //m_list.SetItemText(n, 1, str); xml.Write("\t\t\t<naksatra id=\""); xml.Write(nak); xml.Write("\" name=\""); xml.Write(GCNaksatra.GetName(nak)); xml.Write("\"\n"); dt.SetDegTime(d.shour * 360); //time_print(str, dt); xml.Write("\t\t\t\tstarttime=\""); xml.Write(dt); xml.Write("\" />\n"); //m_list.SetItemText(n, 2, str); //time_print(str, sun.rise); //m_list.SetItemText(n, 3, str); xml.Write("\t\t\t<sunrise time=\""); xml.Write(GCSunData.CalcSunrise(d, earth)); xml.Write("\" />\n"); xml.Write("\t\t</day>\n"); // increment for non-duplication of naksatra d.Set(dn); d.shour += 1.0 / 8.0; } xml.Write("\t</result>\n"); xml.Write("</xml>\n"); } return(1); }
public override GSCore GetPropertyValue(string Token) { GSCore result = null; switch (Token) { case "tithi": result = new GSNumber() { IntegerValue = sunRise.Tithi }; break; case "tithiElapsed": result = new GSNumber() { DoubleValue = sunRise.TithiElapse }; break; case "tithiName": result = new GSString() { Value = GCTithi.GetName(sunRise.Tithi) }; break; case "naksatra": result = new GSNumber() { IntegerValue = sunRise.Naksatra }; break; case "naksatraElapsed": result = new GSNumber() { DoubleValue = sunRise.NaksatraElapse }; break; case "naksatraName": result = new GSString() { Value = GCNaksatra.GetName(sunRise.Naksatra) }; break; case "paksa": result = new GSNumber() { IntegerValue = sunRise.Paksa }; break; case "paksaName": result = new GSString() { Value = GCPaksa.GetName(sunRise.Paksa) }; break; case "paksaAbbr": result = new GSString() { Value = GCPaksa.GetAbbr(sunRise.Paksa).ToString() }; break; case "yoga": result = new GSNumber() { IntegerValue = sunRise.Yoga }; break; case "yogaName": result = new GSString() { Value = GCYoga.GetName(sunRise.Yoga) }; break; case "masa": result = new GSNumber() { IntegerValue = Masa }; break; case "masaName": result = new GSString() { Value = GCMasa.GetName(Masa) }; break; case "masaNameVedic": result = new GSString() { Value = GCMasa.GetNameEx(Masa, 2) }; break; case "masaNameGaudiya": result = new GSString() { Value = GCMasa.GetNameEx(Masa, 0) }; break; case "gaurabdaYear": result = new GSNumber() { IntegerValue = GaurabdaYear }; break; case "arunodayaTime": result = new GCHourTimeObject(sunArunodaya); break; case "arunodayaTithi": result = new GSString(GCTithi.GetName(sunArunodaya.Tithi)); break; case "sunRiseTime": result = new GCHourTimeObject(sunRise); break; case "noonTime": result = new GCHourTimeObject(sunNoon); break; case "sunSetTime": result = new GCHourTimeObject(sunSet); break; case "moonRasi": result = new GSNumber(sunRise.RasiOfMoon); break; case "moonRasiName": result = new GSString(GCRasi.GetName(sunRise.RasiOfMoon)); break; case "sunRasi": result = new GSNumber(sunRise.RasiOfSun); break; case "sunRasiName": result = new GSString(GCRasi.GetName(sunRise.RasiOfSun)); break; case "sunLongitude": result = new GSNumber(sunRise.longitude); break; default: result = base.GetPropertyValue(Token); break; } return(result); }