public static int WriteXML_GaurabdaTithi(StringBuilder doc, GPLocationProvider loc, GPVedicTime vaStart, GPVedicTime 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; } doc.Append("<xml>\n"); doc.Append("\t<request name=\"Tithi\" version=\"" + GPFileHelper.FileVersion + "\">\n"); doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.getLocation(0).GetLongitudeEastPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.getLocation(0).GetLatitudeNorthPositive() + "\" />\n"); doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getLocation(0).getTimeZone().OffsetSeconds / 60 + "\" />\n"); if (gyearA > 1500) { doc.Append("\t\t<arg name=\"year-start\" val=\"" + gyearA + "\" />\n"); doc.Append("\t\t<arg name=\"year-end\" val=\"" + gyearB + "\" />\n"); } else { doc.Append("\t\t<arg name=\"gaurabdayear-start\" val=\"" + gyearA + "\" />\n"); doc.Append("\t\t<arg name=\"gaurabdayear-end\" val=\"" + gyearB + "\" />\n"); } doc.Append("\t\t<arg name=\"masa\" val=\"" + gmasa + "\" />\n"); doc.Append("\t\t<arg name=\"paksa\" val=\"" + gpaksa + "\" />\n"); doc.Append("\t\t<arg name=\"tithi\" val=\"" + gtithi + "\" />\n"); doc.Append("\t</request>\n"); doc.Append("\t<result name=\"Tithi\">\n"); GPGregorianTime vcs = new GPGregorianTime(loc), vce = new GPGregorianTime(loc), today = new GPGregorianTime(loc); GPSun sun = new GPSun(); int A, B; double sunrise; GPAstroData day = new GPAstroData(); int oTithi, oPaksa, oMasa, oYear; if (gyearA > 1500) { A = gyearA - 1487; B = gyearB - 1485; } else { A = gyearA; B = gyearB; } for (; A <= B; A++) { vcs = GPTithi.CalcTithiEnd(A, gmasa, gpaksa, gtithi, loc, out vce); if (gyearA > 1500) { if ((vcs.getYear() < gyearA) || (vcs.getYear() > gyearB)) { continue; } } oTithi = gpaksa * 15 + gtithi; oMasa = gmasa; oPaksa = gpaksa; oYear = 0; doc.Append("\t<celebration\n"); doc.Append("\t\trtithi=\"" + GPTithi.getName(oTithi) + "\"\n"); doc.Append("\t\trmasa=\"" + GPMasa.GetName(oMasa) + "\"\n"); doc.Append("\t\trpaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n"); // test ci je ksaya today.Copy(vcs); today.setDayHours(0.5); sun.SunCalc(today, loc); sunrise = sun.getSunriseDayHours(); if (sunrise < vcs.getDayHours()) { today.Copy(vce); sun.SunCalc(today, loc); sunrise = sun.getSunriseDayHours(); if (sunrise < vce.getDayHours()) { // normal type vcs.NextDay(); doc.Append("\t\ttype=\"normal\"\n"); } else { // ksaya vcs.NextDay(); day.calculateDayData(vcs, loc); oTithi = day.nTithi; oPaksa = day.nPaksa; oMasa = day.determineMasa(vcs, out oYear); doc.Append("\t\ttype=\"ksaya\"\n"); } } else { // normal, alebo prvy den vriddhi today.Copy(vce); sun.SunCalc(today, loc); if (sun.getSunriseDayHours() < vce.getDayHours()) { // first day of vriddhi type doc.Append("\t\ttype=\"vriddhi\"\n"); } else { // normal doc.Append("\t\ttype=\"normal\"\n"); } } doc.Append("\t\tdate=\"" + vcs + "\"\n"); doc.Append("\t\totithi=\"" + GPTithi.getName(oTithi) + "\"\n"); doc.Append("\t\tomasa=\"" + GPMasa.GetName(oMasa) + "\"\n"); doc.Append("\t\topaksa=\"" + GPPaksa.getName(oPaksa) + "\"\n"); doc.Append("\t/>\n"); // doc.Append( "\t\t</celebration>\n"); } doc.Append("\t</result>\n"); doc.Append("</xml>\n"); return(1); }