/// <summary> /// Returns first day of gaurabda vaisnava calendar for given year /// </summary> /// <param name="loc"></param> /// <param name="year"></param> /// <returns></returns> public static DateTime GetFirstDayOfYear(GPLocationProvider loc, int year) { GPGregorianTime vcStart = GPGaurabdaYear.getFirstDayOfYear(loc, year); DateTime dt = new DateTime(vcStart.getYear(), vcStart.getMonth(), vcStart.getDay()); return(dt); }
/*********************************************************************/ /* Finds starting and ending time for given tithi */ /* */ /* tithi is specified by Gaurabda year, masa, paksa and tithi number */ /* nGYear - 0..9999 */ /* nMasa - 0..12, 0-Madhusudana, 1-Trivikrama, 2-Vamana */ /* 3-Sridhara, 4-Hrsikesa, 5-Padmanabha */ /* 6-Damodara, 7-Kesava, 8-narayana, 9-Madhava */ /* 10-Govinda, 11-Visnu, 12-PurusottamaAdhika */ /* nPaksa - 0-Krsna, 1-Gaura */ /* nTithi - 0..14 */ /* earth - used timezone */ /* */ /*********************************************************************/ public static GPGregorianTime CalcTithiEnd(int nGYear, int nMasa, int nPaksa, int nTithi, GPLocationProvider earth, out GPGregorianTime endTithi) { GPGregorianTime d; d = GPGaurabdaYear.getFirstDayOfYear(earth, nGYear + 1486); d.setDayHours(0.5); d.setLocationProvider(earth); return(CalcTithiEndEx(d, nGYear, nMasa, nPaksa, nTithi, earth, out endTithi)); }
public static int WriteXML_FirstDay_Year(StringBuilder doc, GPGregorianTime vcStart) { vcStart = GPGaurabdaYear.getFirstDayOfYear(vcStart.getLocationProvider(), vcStart.getYear()); // write doc.Append("<xml>\n"); doc.Append("\t\t<arg name=\"longitude\" val=\"" + vcStart.getLocation().GetLongitudeEastPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"latitude\" val=\"" + vcStart.getLocation().GetLatitudeNorthPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"year\" val=\"" + vcStart.getYear() + "\" />\n"); doc.Append("\t</request>\n"); doc.Append("\t<result name=\"FirstDay_of_GaurabdaYear\">\n"); doc.Append("\t\t<firstday date=\"" + vcStart + "\" dayweekid = \"" + vcStart.getDayOfWeek() + "\" dayweek=\"" + getSharedStringHtml(vcStart.getDayOfWeek()) + "\" />\n"); doc.Append("\t</result>\n"); doc.Append("</xml>\n"); return(0); }
public void calculateAppearanceDayData(GPLocationProvider aLocation, GPGregorianTime aEvente) { //MOONDATA moon; //SUNDATA sun; location = aLocation; evente = new GPGregorianTime(aEvente); double dd; GPAstroData d = details; GPGregorianTime vc = evente; GPGregorianTime vcsun = evente; b_adhika = false; d.calculateDayData(aEvente, aLocation); //d.nTithi = GetPrevTithiStart(m_earth, vc, dprev); //GetNextTithiStart(m_earth, vc, dnext); //vcsun.setDayHours(vcsun.getDayHours() - vcsun.getTimeZoneOffsetHours() / 24.0); vcsun.normalizeValues(); d.sun.calculateCoordinatesMethodC(vcsun, -1); d.moon.MoonCalc(vcsun.getJulianGreenwichTime()); d.msDistance = GPMath.putIn360(d.moon.longitude_deg - d.sun.eclipticalLongitude - 180.0); d.msAyanamsa = GPAyanamsa.GetAyanamsa(vc.getJulianGreenwichTime()); // tithi dd = d.msDistance / 12.0; d.nTithi = Convert.ToInt32(Math.Floor(dd)); d.nTithiElapse = GPMath.frac(dd) * 100.0; d.nPaksa = (d.nTithi >= 15) ? 1 : 0; // naksatra dd = GPMath.putIn360(d.moon.longitude_deg - d.msAyanamsa); dd = (dd * 3.0) / 40.0; d.nNaksatra = Convert.ToInt32(Math.Floor(dd)); d.nNaksatraElapse = GPMath.frac(dd) * 100.0; d.nMasa = d.determineMasa(vc, out d.nGaurabdaYear); d.nMoonRasi = GPEngine.GetRasi(d.moon.longitude_deg, d.msAyanamsa); d.nSunRasi = GPEngine.GetRasi(d.sun.eclipticalLongitude, d.msAyanamsa); if (d.nMasa == GPMasa.ADHIKA_MASA) { d.nMasa = GPEngine.GetRasi(d.sun.eclipticalLongitude, d.msAyanamsa); b_adhika = true; } string dstApplicable = ""; //List<string> gstr = GPStrings.getSharedStrings().gstr; output.Add(new GPStringPair(GPStrings.getString(25), "", true)); output.Add(new GPStringPair(GPStrings.getString(7), vc.ToString())); output.Add(new GPStringPair(GPStrings.getString(8), vc.getShortTimeString(true, ref dstApplicable))); output.Add(new GPStringPair(GPStrings.getString(9), vc.getLocation().getFullName())); //output.Add(new GPStringPair(gstr[10], vc.getLocation().getLatitudeString())); //output.Add(new GPStringPair(gstr[11], vc.getLocation().getLongitudeString())); //output.Add(new GPStringPair(gstr[12], vc.getLocation().getTimeZoneName())); //output.Add(new GPStringPair(gstr[1001], dstApplicable)); output.Add(new GPStringPair(GPStrings.getString(13), GPTithi.getName(d.nTithi))); output.Add(new GPStringPair(GPStrings.getString(14), string.Format("{0:0.###} %", d.nTithiElapse))); output.Add(new GPStringPair(GPStrings.getString(15), GPNaksatra.getName(d.nNaksatra))); output.Add(new GPStringPair(GPStrings.getString(16), string.Format("{0:0.###} % ({1})", d.nNaksatraElapse, GPStrings.getString(811 + Convert.ToInt32(d.nNaksatraElapse / 25.0))))); output.Add(new GPStringPair(GPStrings.getString(991), GPSankranti.getName(d.nMoonRasi))); output.Add(new GPStringPair(GPStrings.getString(992), GPSankranti.getName(d.nSunRasi))); output.Add(new GPStringPair(GPStrings.getString(20), GPPaksa.getName(d.nPaksa))); if (b_adhika == true) { output.Add(new GPStringPair(GPStrings.getString(22), string.Format("{0} {1}", GPMasa.GetName(d.nMasa), GPStrings.getString(21)))); } else { output.Add(new GPStringPair(GPStrings.getString(22), GPMasa.GetName(d.nMasa))); } output.Add(new GPStringPair(GPStrings.getString(23), d.nGaurabdaYear.ToString())); if (GPDisplays.AppDay.childNameSuggestions()) { output.Add(new GPStringPair()); output.Add(new GPStringPair(GPStrings.getString(17), "", true)); output.Add(new GPStringPair()); output.Add(new GPStringPair(GPStrings.getString(18), string.Format("{0}...", GPAppHelper.GetNaksatraChildSylable(d.nNaksatra, Convert.ToInt32(d.nNaksatraElapse / 25.0))))); output.Add(new GPStringPair(GPStrings.getString(19), string.Format("{0}...", GPAppHelper.GetRasiChildSylable(d.nMoonRasi)))); } vc.Today(); GPVedicTime va = new GPVedicTime(); GPGregorianTime vctemp; va.tithi = d.nTithi; va.masa = d.nMasa; va.gyear = GPGaurabdaYear.getGaurabdaYear(vc, location); if (va.gyear < d.nGaurabdaYear) { va.gyear = d.nGaurabdaYear; } int countC = GPUserDefaults.IntForKey("appday.celebs", 3); if (countC > 0) { output.Add(new GPStringPair()); output.Add(new GPStringPair(GPStrings.getString(24), "", true)); output.Add(new GPStringPair()); } int m = 0; for (int i = 0; i < 6; i++) { GPEngine.VATIMEtoVCTIME(va, out vctemp, location); if (va.gyear > d.nGaurabdaYear) { if (m < countC) { output.Add(new GPStringPair(string.Format("{0} {1}", GPStrings.getString(994), va.gyear), vctemp.ToString())); m++; } } va.gyear++; } }
/// <summary> /// Main function of this class /// </summary> /// <param name="args"></param> /// <returns></returns> public bool ParseCommandArguments(string[] args) { GPLocationProvider loc = new GPLocationProvider(); GPLocation loc1 = new GPLocation(); GPGregorianTime vcStart = new GPGregorianTime(loc), vcEnd = new GPGregorianTime(loc); GPVedicTime vaStart = new GPVedicTime(), vaEnd = new GPVedicTime(); int nCount; int nReq = 0; string strFileOut = ""; try { loc1.setLatitudeNorthPositive(0.0); loc1.setLongitudeEastPositive(0.0); loc1.setTimeZoneName(""); loc.setDefaultLocation(loc1); vcStart.Clear(); vcEnd = vcStart; vaStart.tithi = vaStart.masa = vaStart.gyear = 0; vaEnd = vaStart; nCount = -1; int argc = args.Length; for (int i = 0; i < argc; i++) { //TRACE2("arg %d = %s\n", i, args[i]); if (args[i] == "-L") { if (argc >= i + 2) { loc1.setLongitudeString(args[i + 1]); double lat = 0.0; double longi = 0.0; GetArg_EarthPos(args[i + 1], ref lat, ref longi); loc1.setLongitudeEastPositive(longi); loc1.setLatitudeNorthPositive(lat); //TRACE2("-L latitude=%f longitude=%f\n", loc.m_fLatitude, loc.m_fLongitude); } i++; } else if (args[i] == "-N") { if (argc >= i + 2) { loc1.setCity(args[i + 1]); //TRACE1("-N name=%s\n", loc.m_strName); } i++; } else if (args[i] == "-SV") { if (argc >= i + 2) { GetArg_VaisnDate(args[i + 1], out vaStart); } i++; } else if (args[i] == "-SG") { if (argc >= i + 2) { GetArg_Date(args[i + 1], out vcStart); } i++; } else if (args[i] == "-ST") { if (argc >= i + 2) { GetArg_Time(args[i + 1], out vcStart); } i++; } else if (args[i] == "-EG") { if (argc >= i + 2) { GetArg_Date(args[i + 1], out vcEnd); //AfxTrace("-EG day=%d month=%d year=%d\n", vcEnd.day, vcEnd.month, vcEnd.year); } i++; } else if (args[i] == "-EV") { if (argc >= i + 2) { GetArg_VaisnDate(args[i + 1], out vaEnd); //AfxTrace("-EV tithi=%d masa=%d gyear=%d\n", vaEnd.tithi, vaEnd.masa, vaEnd.gyear); } i++; } else if (args[i] == "-EC") { if (argc >= i + 2) { int.TryParse(args[i + 1], out nCount); } i++; } else if (args[i] == "-TZ") { if (argc >= i + 2) { loc1.setTimeZoneName(args[i + 1]); } i++; } else if (args[i] == "-O") { if (argc >= i + 2) { strFileOut = args[i + 1]; } i++; } else if (args[i] == "-R") { if (argc >= i + 2) { if (args[i + 1] == "calendar") { nReq = 10; } else if (args[i + 1] == "appday") { nReq = 11; } else if (args[i + 1] == "tithi") { nReq = 12; } else if (args[i + 1] == "sankranti") { nReq = 13; } else if (args[i + 1] == "naksatra") { nReq = 14; } else if (args[i + 1] == "firstday") { nReq = 15; } else if (args[i + 1] == "gcalendar") { nReq = 16; } else if (args[i + 1] == "gtithi") { nReq = 17; } else if (args[i + 1] == "next") { nReq = 18; } else if (args[i + 1] == "help") { nReq = 60; } /*else if (args[i+1] == "") * { * } else if (args[i+1] == "") * { * } else if (args[i+1] == "") * { * } else if (args[i+1] == "") * { * }*/ } i++; } } vcStart.setLocationProvider(loc); vcEnd.setLocationProvider(loc); switch (nReq) { case 10: case 13: case 14: if (vcStart.getYear() == 0 && vaStart.gyear != 0) { GPEngine.VATIMEtoVCTIME(vaStart, out vcStart, loc); } if (vcEnd.getYear() == 0 && vaEnd.gyear != 0) { GPEngine.VATIMEtoVCTIME(vaEnd, out vcEnd, loc); } break; default: break; } if (vcStart.getYear() != 0 && vcEnd.getYear() != 0 && nCount < 0) { nCount = Convert.ToInt32(vcEnd.getJulianLocalNoon() - vcStart.getJulianLocalNoon()); } if (nCount < 0) { nCount = 30; } GPAppDayResults appday = new GPAppDayResults(); GPCalendarResults calendar = new GPCalendarResults(); //AfxTrace("Count === %d\n", nCount); StringBuilder fout = new StringBuilder(); switch (nReq) { case 10: // -R -O -LAT -LON -SG -C [-DST -NAME] vcStart.NextDay(); vcStart.PreviousDay(); calendar.CalculateCalendar(vcStart, nCount); FormaterXml.WriteXml(FormaterXml.GetCalendarXmlDocument(calendar), fout); break; case 11: // -R -O -LAT -LON -SG -ST [-NAME] appday.calculateAppearanceDayData(loc, vcStart); FormaterXml.FormatAppDayXML(appday, fout); break; case 12: FormaterXml.WriteXML_Tithi(fout, loc, vcStart); break; case 13: if (vcEnd.getYear() == 0) { vcEnd = vcStart; vcEnd.AddDays(nCount); } FormaterXml.WriteXml(FormaterXml.GetSankrantiXml(loc, vcStart, vcEnd), fout); break; case 14: FormaterXml.WriteXML_Naksatra(fout, loc, vcStart, nCount); break; case 15: FormaterXml.WriteXML_FirstDay_Year(fout, vcStart); break; case 16: vcStart = GPGaurabdaYear.getFirstDayOfYear(loc, vcStart.getYear()); vcEnd = GPGaurabdaYear.getFirstDayOfYear(loc, vcStart.getYear() + 1); nCount = Convert.ToInt32(vcEnd.getJulianLocalNoon() - vcStart.getJulianLocalNoon()); calendar.CalculateCalendar(vcStart, nCount); FormaterXml.WriteXml(FormaterXml.GetCalendarXmlDocument(calendar), fout); break; case 17: FormaterXml.WriteXML_GaurabdaTithi(fout, loc, vaStart, vaEnd); break; case 18: FormaterXml.WriteXML_GaurabdaNextTithi(fout, loc, vcStart, vaStart); break; } // application should be windowless // since some parameters are present File.WriteAllText(strFileOut, fout.ToString()); } catch (Exception ex) { Console.WriteLine("Exception during execution: " + ex.Message); } return(true); }
public int CalcMasaList(GPLocationProvider loc, int nYear, int nCount) { GPMasaListResults mlist = this; GPAstroData day = new GPAstroData(); GPGregorianTime d = new GPGregorianTime(loc); GPGregorianTime de = new GPGregorianTime(loc); GPGregorianTime t = new GPGregorianTime(loc); vc_end = new GPGregorianTime(loc); vc_start = new GPGregorianTime(loc); int lm = -1; mlist.n_startYear = nYear; mlist.n_countYears = nCount; d.Copy(GPGaurabdaYear.getFirstDayOfYear(loc, nYear)); de.Copy(GPGaurabdaYear.getFirstDayOfYear(loc, nYear + nCount)); mlist.vc_start.Copy(d); mlist.vc_end.Copy(de); mlist.m_location = loc; alloc(nCount); int i = 0; int prev_paksa = -1; int current = 0; while (d.IsBeforeThis(de)) { day.calculateDayData(d, loc); if (prev_paksa != day.nPaksa) { day.nMasa = day.determineMasa(d, out day.nGaurabdaYear); if (lm != day.nMasa) { if (lm >= 0) { t.Copy(d); t.PreviousDay(); mlist.arr[current].vc_end.Copy(t); current++; } lm = day.nMasa; mlist.arr[current].masa = day.nMasa; mlist.arr[current].year = day.nGaurabdaYear; mlist.arr[current].vc_start.Copy(d); } } prev_paksa = day.nPaksa; d.NextDay(); i++; } t.Copy(d); mlist.arr[current].vc_end.Copy(t); current++; mlist.n_countMasa = current; return(1); }