//=========================================================================== // //=========================================================================== public static void VCTIMEtoVATIME(GregorianDateTime vc, out GaurabdaDate va, GCEarthData earth) { GCAstroData day = new GCAstroData(); day.DayCalc(vc, earth); va = new GaurabdaDate(); va.masa = day.MasaCalc(vc, earth); va.tithi = day.sunRise.Tithi; va.gyear = day.GaurabdaYear; }
public static int writeGaurabdaNextTithiXml(string fileName, GCLocation loc, GregorianDateTime vcStart, GaurabdaDate vaStart) { int gmasa, gpaksa, gtithi; GCHourTime sunRise; using (StreamWriter xml = new StreamWriter(fileName)) { gmasa = vaStart.masa; gpaksa = vaStart.tithi / 15; gtithi = vaStart.tithi % 15; xml.Write("<xml>\n"); xml.Write("\t<request name=\"Tithi\" 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=\"start date\" val=\""); xml.Write(vcStart); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"masa\" val=\""); xml.Write(gmasa); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"paksa\" val=\""); xml.Write(gpaksa); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"tithi\" val=\""); xml.Write(gtithi); xml.Write("\" />\n"); xml.Write("\t</request>\n"); xml.Write("\t<result name=\"Tithi\">\n"); GCEarthData earth = loc.GetEarthData(); GregorianDateTime vcs = new GregorianDateTime(), vce = new GregorianDateTime(), today = new GregorianDateTime(); //GCSunData sun = new GCSunData(); int A; double sunrise; GCAstroData day = new GCAstroData(); int oTithi, oPaksa, oMasa, oYear; today.Set(vcStart); today.PreviousDay(); vcStart.SubtractDays(15); for (A = 0; A <= 3; A++) { vcs.Set(GCTithi.CalcTithiEndEx(vcStart, 0, gmasa, gpaksa, gtithi, earth, out vce)); if (!vcs.IsBeforeThis(today)) { oTithi = gpaksa * 15 + gtithi; oMasa = gmasa; oPaksa = gpaksa; oYear = 0; xml.Write("\t<celebration\n"); // xml.Write("\t\t<tithi\n"; xml.Write("\t\trtithi=\""); xml.Write(GCTithi.GetName(oTithi)); xml.Write("\"\n"); xml.Write("\t\trmasa=\""); xml.Write(GCMasa.GetName(oMasa)); xml.Write("\"\n"); xml.Write("\t\trpaksa=\""); xml.Write((oPaksa != 0 ? "Gaura" : "Krsna")); xml.Write("\"\n"); // test ci je ksaya today.Set(vcs); today.shour = 0.5; sunRise = GCSunData.CalcSunrise(today, earth); sunrise = sunRise.TotalDays; if (sunrise < vcs.shour) { today.Set(vce); sunRise = GCSunData.CalcSunrise(today, earth); sunrise = sunRise.TotalDays; if (sunrise < vce.shour) { // normal type vcs.NextDay(); xml.Write("\t\ttype=\"normal\"\n"); } else { // ksaya vcs.NextDay(); day.DayCalc(vcs, earth); oTithi = day.sunRise.Tithi; oPaksa = day.sunRise.Paksa; oMasa = day.MasaCalc(vcs, earth); oYear = day.GaurabdaYear; xml.Write("\t\ttype=\"ksaya\"\n"); } } else { // normal, alebo prvy den vriddhi today.Set(vce); sunRise = GCSunData.CalcSunrise(today, earth); if (sunRise.TotalDays < vce.shour) { // first day of vriddhi type xml.Write("\t\ttype=\"vriddhi\"\n"); } else { // normal xml.Write("\t\ttype=\"normal\"\n"); } } xml.Write("\t\tdate=\""); xml.Write(vcs); xml.Write("\"\n"); xml.Write("\t\totithi=\""); xml.Write(GCTithi.GetName(oTithi)); xml.Write("\"\n"); xml.Write("\t\tomasa=\""); xml.Write(GCMasa.GetName(oMasa)); xml.Write("\"\n"); xml.Write("\t\topaksa=\""); xml.Write(GCPaksa.GetName(oPaksa)); xml.Write("\"\n"); xml.Write("\t/>\n"); break; } else { vcStart.Set(vcs); vcs.NextDay(); } } xml.Write("\t</result>\n"); xml.Write("</xml>\n"); } return(1); }
public static int writeGaurabdaTithiXml(string fileName, GCLocation loc, GaurabdaDate vaStart, GaurabdaDate vaEnd) { int gyearA = vaStart.gyear; int gyearB = vaEnd.gyear; int gmasa = vaStart.masa; int gpaksa = vaStart.tithi / 15; int gtithi = vaStart.tithi % 15; if (gyearB < gyearA) { gyearB = gyearA; } using (StreamWriter xml = new StreamWriter(fileName)) { xml.Write("<xml>\n"); xml.Write("\t<request name=\"Tithi\" 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"); if (gyearA > 1500) { xml.Write("\t\t<arg name=\"year-start\" val=\""); xml.Write(gyearA); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"year-end\" val=\""); xml.Write(gyearB); xml.Write("\" />\n"); } else { xml.Write("\t\t<arg name=\"gaurabdayear-start\" val=\""); xml.Write(gyearA); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"gaurabdayear-end\" val=\""); xml.Write(gyearB); xml.Write("\" />\n"); } xml.Write("\t\t<arg name=\"masa\" val=\""); xml.Write(gmasa); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"paksa\" val=\""); xml.Write(gpaksa); xml.Write("\" />\n"); xml.Write("\t\t<arg name=\"tithi\" val=\""); xml.Write(gtithi); xml.Write("\" />\n"); xml.Write("\t</request>\n"); xml.Write("\t<result name=\"Tithi\">\n"); GCEarthData earth = loc.GetEarthData(); GregorianDateTime vcs = new GregorianDateTime(), vce = new GregorianDateTime(), today = new GregorianDateTime(); GCHourTime sun = new GCHourTime(); int A, B; double sunrise; GCAstroData day = new GCAstroData(); int oTithi, oPaksa, oMasa, oYear; if (gyearA > 1500) { A = gyearA - 1487; B = gyearB - 1485; } else { A = gyearA; B = gyearB; } for (; A <= B; A++) { vcs.Set(GCTithi.CalcTithiEnd(A, gmasa, gpaksa, gtithi, earth, out vce)); if (gyearA > 1500) { if ((vcs.year < gyearA) || (vcs.year > gyearB)) { continue; } } oTithi = gpaksa * 15 + gtithi; oMasa = gmasa; oPaksa = gpaksa; oYear = 0; xml.Write("\t<celebration\n"); // xml.Write("\t\t<tithi\n"; xml.Write("\t\trtithi=\""); xml.Write(GCTithi.GetName(oTithi)); xml.Write("\"\n"); xml.Write("\t\trmasa=\""); xml.Write(GCMasa.GetName(oMasa)); xml.Write("\"\n"); xml.Write("\t\trpaksa=\""); xml.Write(oPaksa != 0 ? "Gaura" : "Krsna"); xml.Write("\"\n"); // test ci je ksaya today.Set(vcs); today.shour = 0.5; sun = GCSunData.CalcSunrise(today, earth); sunrise = sun.TotalDays; if (sunrise < vcs.shour) { today.Set(vce); sun = GCSunData.CalcSunrise(today, earth); sunrise = sun.TotalDays; if (sunrise < vce.shour) { // normal type vcs.NextDay(); xml.Write("\t\ttype=\"normal\"\n"); } else { // ksaya vcs.NextDay(); day.DayCalc(vcs, earth); oTithi = day.sunRise.Tithi; oPaksa = day.sunRise.Paksa; oMasa = day.MasaCalc(vcs, earth); oYear = day.GaurabdaYear; xml.Write("\t\ttype=\"ksaya\"\n"); } } else { // normal, alebo prvy den vriddhi today.Set(vce); sun = GCSunData.CalcSunrise(today, earth); if (sun.TotalDays < vce.shour) { // first day of vriddhi type xml.Write("\t\ttype=\"vriddhi\"\n"); } else { // normal xml.Write("\t\ttype=\"normal\"\n"); } } xml.Write("\t\tdate=\""); xml.Write(vcs); xml.Write("\"\n"); xml.Write("\t\totithi=\""); xml.Write(GCTithi.GetName(oTithi)); xml.Write("\"\n"); xml.Write("\t\tomasa=\""); xml.Write(GCMasa.GetName(oMasa)); xml.Write("\"\n"); xml.Write("\t\topaksa=\""); xml.Write(GCPaksa.GetName(oPaksa)); xml.Write("\"\n"); xml.Write("\t/>\n"); } xml.Write("\t</result>\n"); xml.Write("</xml>\n"); } return(1); }
//=========================================================================== // //=========================================================================== public static void VATIMEtoVCTIME(GaurabdaDate va, out GregorianDateTime vc, GCEarthData earth) { vc = GCTithi.CalcTithiDate(va.gyear, va.masa, va.tithi / 15, va.tithi % 15, earth); }
public static string FormatDate(GregorianDateTime vc, GaurabdaDate va) { return(string.Format("{0} {1} {2}\r\n{3}, {4} Paksa, {5} Masa, {6}", vc.day, GregorianDateTime.GetMonthAbreviation(vc.month), vc.year, GCTithi.GetName(va.tithi % 15), GCPaksa.GetName(va.tithi / 15), GCMasa.GetName(va.masa), va.gyear)); }
public static bool CalcEndDate(GCEarthData m_earth, GregorianDateTime vcStart, out GregorianDateTime vcEnd, PeriodUnit nType, int nCount) { if (m_earth == null || vcStart == null) { vcEnd = null; return(false); } GaurabdaDate vaStart = new GaurabdaDate(); VCTIMEtoVATIME(vcStart, out vaStart, m_earth); vcEnd = new GregorianDateTime(); GaurabdaDate vaEnd = new GaurabdaDate(); if (nCount > LimitForPeriodUnit(nType)) { nCount = LimitForPeriodUnit(nType); } switch (nType) { case PeriodUnit.Days: vcEnd.Set(vcStart); vcEnd.AddDays(nCount); VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth); break; case PeriodUnit.Weeks: vcEnd.Set(vcStart); vcEnd.AddDays(nCount * 7); VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth); break; case PeriodUnit.Months: vcEnd.Set(vcStart); vcEnd.month += nCount; while (vcEnd.month > 12) { vcEnd.year++; vcEnd.month -= 12; } VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth); break; case PeriodUnit.Years: vcEnd.Set(vcStart); vcEnd.year += nCount; VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth); break; case PeriodUnit.Tithis: vaEnd.Set(vaStart); vaEnd.tithi += nCount; while (vaEnd.tithi >= 30) { vaEnd.tithi -= 30; vaEnd.masa++; } while (vaEnd.masa >= 12) { vaEnd.masa -= 12; vaEnd.gyear++; } VATIMEtoVCTIME(vaEnd, out vcEnd, m_earth); break; case PeriodUnit.Masas: vaEnd.Set(vaStart); vaEnd.masa = MasaToComboMasa(vaEnd.masa); if (vaEnd.masa == (int)MasaId.ADHIKA_MASA) { vcEnd.Set(vcStart); vcEnd.month += nCount; while (vcEnd.month > 12) { vcEnd.year++; vcEnd.month -= 12; } VCTIMEtoVATIME(vcEnd, out vaEnd, m_earth); vaEnd.tithi = vaStart.tithi; VATIMEtoVCTIME(vaEnd, out vcEnd, m_earth); } else { vaEnd.masa += nCount; while (vaEnd.masa >= 12) { vaEnd.masa -= 12; vaEnd.gyear++; } vaEnd.masa = ComboMasaToMasa(vaEnd.masa); VATIMEtoVCTIME(vaEnd, out vcEnd, m_earth); } break; case PeriodUnit.Gaurabda: vaEnd.Set(vaStart); vaEnd.gyear += nCount; VATIMEtoVCTIME(vaEnd, out vcEnd, m_earth); break; } return(true); }
public void Set(GaurabdaDate va) { tithi = va.tithi; masa = va.masa; gyear = va.gyear; }
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++; } }