Example #1
0
 public override string ToString()
 {
     return(string.Format("{0} {1}, {2} {3}, {4} {5}, {6} {7}", GPTithi.getName(tithi), GPStrings.getString(13),
                          GPPaksa.getName(tithi / 15), GPStrings.getString(20),
                          GPMasa.GetName(masa), GPStrings.getString(22),
                          GPStrings.getString(994), gyear));
 }
Example #2
0
        public static string GetTextRtf(GPCalendarDay pvd)
        {
            String str;

            str = string.Format("\\par {0} {1} {2} {3}\\tab {4}\\tab {5} ", pvd.date.getDay().ToString().PadLeft(2), GPAppHelper.getMonthAbr(pvd.date.getMonth()), pvd.date.getYear()
                                , pvd.getWeekdayAbbr(), pvd.getTithiNameExtended(), (GPDisplays.Calendar.PaksaInfoVisible() ? GPPaksa.getAbbreviation(pvd.astrodata.nPaksa) : " "));

            if (GPDisplays.Calendar.YogaVisible())
            {
                str += string.Format("\\tab {0}", GPYoga.getName(pvd.astrodata.nYoga));
            }

            if (GPDisplays.Calendar.NaksatraVisible())
            {
                str += string.Format("\\tab {0}", GPNaksatra.getName(pvd.astrodata.nNaksatra));
            }

            if (pvd.nFastType != GPConstants.FAST_NULL && GPDisplays.Calendar.FastingFlagVisible())
            {
                str += "\\tab *";
            }
            else if (GPDisplays.Calendar.FastingFlagVisible())
            {
                str += "\\tab ";
            }

            if (GPDisplays.Calendar.RasiVisible())
            {
                str += string.Format("\\tab {0}", GPSankranti.getName(pvd.astrodata.moon.GetRasi(pvd.astrodata.msAyanamsa)));
            }

            str += "\r\n";

            return(str);
        }
Example #3
0
 public string getPaksaAbbreviation()
 {
     return(GPPaksa.getAbbreviation(astrodata.nPaksa));
 }
Example #4
0
 public string getPaksaName()
 {
     return(string.Format("{0} {1}", GPPaksa.getName(astrodata.nPaksa), GPStrings.getString(20)));
 }
Example #5
0
        public static void AvcGetTodayInfo(GPGregorianTime vc, GPLocationProvider loc, StringBuilder str)
        {
            string str2;

            GPCalendarResults db = new GPCalendarResults();

            GPGregorianTime vc2 = new GPGregorianTime(vc);

            vc2.AddDays(-4);
            db.CalculateCalendar(vc2, 9);

            int           i = db.FindDate(vc);
            GPCalendarDay p = db.get(i);

            if (p == null)
            {
                return;
            }

            str.AppendFormat("{0}, {1} {2}", loc.getFullName(), loc.getLocation(0).getLatitudeString(), loc.getLocation(0).getLongitudeString());
            str.AppendLine();
            str.AppendFormat("{0}: {1}", getSharedStringPlain(12), loc.getLocation(0).getTimeZoneString());
            str.AppendLine();
            str.AppendLine();
            str.AppendFormat("[{0} - {1}]", vc, getSharedStringPlain(vc.getDayOfWeek()));
            str.AppendLine();
            str.AppendFormat("  {0}, {1} {2}", GPTithi.getName(p.astrodata.nTithi), GPPaksa.getName(p.astrodata.nPaksa), getSharedStringPlain(20));
            str.AppendLine();
            str.Append("  ");
            str.AppendFormat("{0}, {1}", p.getMasaLongName(), p.getGaurabdaYearLongString());
            str.AppendLine();
            str.AppendLine();

            if (p.hasEkadasiParana())
            {
                str.AppendLine(p.getEkadasiParanaString());
            }

            // adding mahadvadasi
            // adding spec festivals

            foreach (GPCalendarDay.Festival fest in p.CompleteFestivalList(db.get(i - 1), db.get(i + 1)))
            {
                if (GPUserDefaults.BoolForKey(fest.ShowSettingItem, true))
                {
                    if (fest.ShowSettingItem == GPDisplays.Keys.CalendarSankranti)
                    {
                        str.AppendLine(GPAppHelper.CenterString(fest.Text, 80, '-'));
                    }
                    else
                    {
                        str.AppendFormat("   {0}", fest.Text);
                        str.AppendLine();
                    }
                }
            }


            str.AppendLine();


            if (GPDisplays.Today.BrahmaMuhurtaVisible())
            {
                str.AppendLine();
                str.AppendFormat("{0} {1}", getSharedStringPlain(988), p.astrodata.sun.arunodaya.getShortMuhurtaRange(0));
            }

            if (GPDisplays.Today.SunriseVisible())
            {
                str.AppendLine();
                str2 = string.Format("{0} {1} ",
                                     getSharedStringPlain(51), p.astrodata.sun.rise.getShortTimeString());
                str.Append(str2);
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1}", getSharedStringPlain(989), p.astrodata.sun.rise.getShortSandhyaRange());
                }
                str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.AppendLine();
            }
            if (GPDisplays.Today.NoonVisible())
            {
                str2 = string.Format("{0}    {1} ", getSharedStringPlain(857), p.astrodata.sun.noon.getShortTimeString());
                str.Append(str2);
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1} ", getSharedStringPlain(989), p.astrodata.sun.noon.getShortSandhyaRange());
                }
                str2 = string.Format(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.Append(str2);
                str.AppendLine();
            }
            if (GPDisplays.Today.SunsetVisible())
            {
                str2 = string.Format("{0}  {1} ", getSharedStringPlain(52), p.astrodata.sun.set.getShortTimeString());
                str.Append(str2);
                if (GPDisplays.Today.SandhyaTimesVisible())
                {
                    str.AppendFormat(" {0} {1} ", getSharedStringPlain(989), p.astrodata.sun.set.getShortSandhyaRange());
                }
                str.AppendFormat(" ({0})", GPAppHelper.GetDSTSignature(p.isDaylightInEffect()));
                str.AppendLine();
            }

            if (GPDisplays.Today.SunriseInfo())
            {
                str.AppendLine();
                str.AppendLine(getSharedStringPlain(990));
                str.AppendLine();
                str.AppendFormat("   {0} {1}", GPNaksatra.getName(p.astrodata.nNaksatra), getSharedStringPlain(15));
                if (GPDisplays.Today.NaksatraPadaVisible())
                {
                    str.AppendFormat(", {0} {1} ({2})", p.getNaksatraElapsedString(), getSharedStringPlain(993), getSharedStringPlain(811 + p.getNaksatraPada()));
                }
                if (GPDisplays.Today.RasiOfMoonVisible())
                {
                    str.AppendFormat(", {0}: {1}", getSharedStringPlain(991), GPSankranti.getName(p.astrodata.nMoonRasi), getSharedStringPlain(105));
                }
                str.AppendFormat(", {0} {1}", GPYoga.getName(p.astrodata.nYoga), getSharedStringPlain(104));
                str.AppendLine();
                str.AppendFormat("   {0}: {1}.", getSharedStringPlain(992), GPSankranti.getName(p.astrodata.nSunRasi));
                str.AppendLine();
            }

            AddNoteText(str);
        }
Example #6
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++;
            }
        }
Example #7
0
        public static string GetTextA(GPCalendarDay pvd)
        {
            string str;
            String s1, s2;

            s1 = pvd.getTithiNameExtended();

            s2  = GPStrings.getString(150 + pvd.date.getDayOfWeek());
            str = string.Format("{0} {1} {2} {3}  {4}{5} ", pvd.date.getDay().ToString().PadLeft(2), GPAppHelper.getMonthAbr(pvd.date.getMonth()), pvd.date.getYear()
                                , s2, s1.PadRight(34), (GPDisplays.Calendar.PaksaInfoVisible() ? GPPaksa.getAbbreviation(pvd.astrodata.nPaksa) : " "));

            if (GPDisplays.Calendar.YogaVisible())
            {
                str += GPYoga.getName(pvd.astrodata.nYoga).PadRight(10);
            }

            if (GPDisplays.Calendar.NaksatraVisible())
            {
                str += GPNaksatra.getName(pvd.astrodata.nNaksatra).PadRight(15);
            }

            if (pvd.nFastType != GPConstants.FAST_NULL && GPDisplays.Calendar.FastingFlagVisible())
            {
                str += " *";
            }
            else
            {
                str += "  ";
            }

            if (GPDisplays.Calendar.RasiVisible())
            {
                str += "   ";
                str += pvd.getRasiOfMoonName().PadRight(15);
            }

            return(str);
        }
Example #8
0
        public static int WriteXML_GaurabdaNextTithi(StringBuilder doc, GPLocationProvider loc, GPGregorianTime vcStart, GPVedicTime vaStart)
        {
            int gmasa, gpaksa, gtithi;


            gmasa  = vaStart.masa;
            gpaksa = vaStart.tithi / 15;
            gtithi = vaStart.tithi % 15;

            doc.Append("<xml>\n");
            doc.Append("\t<request name=\"Tithi\" version=\"" + GPFileHelper.FileVersion + "\">\n");
            doc.Append("\t\t<arg name=\"longitude\" val=\"" + loc.GetLongitudeEastPositive() + "\" />\n");
            doc.Append("\t\t<arg name=\"latitude\" val=\"" + loc.GetLatitudeNorthPositive() + "\" />\n");
            doc.Append("\t\t<arg name=\"timezone\" val=\"" + loc.getTimeZone().OffsetSeconds / 60 + "\" />\n");
            doc.Append("\t\t<arg name=\"start date\" val=\"" + vcStart + "\" />\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);
            GPGregorianTime vce   = new GPGregorianTime(loc);
            GPGregorianTime today = new GPGregorianTime(loc);
            GPSun           sun   = new GPSun();
            int             A;
            double          sunrise;
            GPAstroData     day = new GPAstroData();
            int             oTithi, oPaksa, oMasa, oYear;

            today.Copy(vcStart);
            today.PreviousDay();
            vcStart.SubDays(15);
            for (A = 0; A <= 3; A++)
            {
                vcs = GPTithi.CalcTithiEndEx(vcStart, 0, gmasa, gpaksa, gtithi, loc, out vce);
                if (!vcs.IsBeforeThis(today))
                {
                    oTithi = gpaksa * 15 + gtithi;
                    oMasa  = gmasa;
                    oPaksa = gpaksa;
                    oYear  = 0;
                    doc.Append("\t<celebration\n");
                    //		doc.Append( "\t\t<tithi\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");
                    break;
                }
                else
                {
                    vcStart.Copy(vcs);
                    vcs.NextDay();
                }
            }

            doc.Append("\t</result>\n");
            doc.Append("</xml>\n");


            return(1);
        }
Example #9
0
        public static void FormatAppDayXML(GPAppDayResults app, StringBuilder strResult)
        {
            GPAstroData     d = app.details;
            string          str;
            GPGregorianTime vc      = app.evente;
            StringBuilder   strText = strResult;
            int             npada;
            bool            bDuringAdhika = false;

            strText.AppendFormat(
                "<xml>\n" +
                "\t<request name=\"AppDay\" version=\"{0}\">\n" +
                "\t\t<arg name=\"longitude\" value=\"{1}\" />\n" +
                "\t\t<arg name=\"latitude\" value=\"{2}\" />\n" +
                "\t\t<arg name=\"timezone\" value=\"{3}\" />\n" +
                "\t\t<arg name=\"year\" value=\"{4}\" />\n" +
                "\t\t<arg name=\"month\" value=\"{5}\" />\n" +
                "\t\t<arg name=\"day\" value=\"{6}\" />\n" +
                "\t\t<arg name=\"hour\" value=\"{7}\" />\n" +
                "\t\t<arg name=\"minute\" value=\"{8}\" />\n" +
                "\t</request>\n", GPFileHelper.FileVersion,
                app.evente.getLocation().GetLongitudeEastPositive(), app.evente.getLocation().GetLatitudeNorthPositive(),
                app.evente.getLocation().getTimeZoneName(),
                app.evente.getYear(), app.evente.getMonth(), app.evente.getDay(), app.evente.getHour(), app.evente.getMinuteRound()
                );


            npada = Convert.ToInt32(d.nNaksatraElapse / 25.0) + 1;
            if (npada > 4)
            {
                npada = 4;
            }

            str = string.Format("\t<result name=\"AppDay\" >\n" +
                                "\t\t<tithi name=\"{0}\" elapse=\"{1}\" />\n" +
                                "\t\t<naksatra name=\"{2}\" elapse=\"{3}\" pada=\"{4}\"/>\n" +
                                "\t\t<paksa name=\"{5}\" />\n" +
                                "\t\t<masa name=\"{6}\" adhikamasa=\"{7}\"/>\n" +
                                "\t\t<gaurabda value=\"{8}\" />\n"

                                , GPTithi.getName(d.nTithi), d.nTithiElapse
                                , GPNaksatra.getName(d.nNaksatra), d.nNaksatraElapse, npada
                                , GPPaksa.getName(d.nPaksa)
                                , GPMasa.GetName(d.nMasa), (bDuringAdhika ? "yes" : "no")
                                , d.nGaurabdaYear
                                );

            strText.Append(str);;
            string prefix = string.Format("{0} ", getSharedStringHtml(994));

            strText.Append("\t\t<celebrations>\n");
            foreach (GPStringPair rec in app.output)
            {
                if (rec.Name.StartsWith(prefix))
                {
                    str = string.Format("\t\t\t<celebration gaurabda=\"{0}\" date=\"{1}\" />\n", rec.Name, rec.Value);
                    strText.Append(str);
                }
            }

            strText.Append("\t\t</celebrations>\n\t</result>\n</xml>\n");
        }
Example #10
0
        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);
        }
Example #11
0
        public static XmlDocument GetCalendarXmlDocument(GPCalendarResults daybuff)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement  e1, e2, e3, eday, e5, e6;
            int         k;
            string      str, st;

            GPCalendarDay pvd;
            int           nPrevMasa = -1;

            e1 = doc.CreateElement("xml");
            doc.AppendChild(e1);

            e2 = doc.CreateElement("request");
            e1.AppendChild(e2);
            e2.SetAttribute("name", "Calendar");
            e2.SetAttribute("version", GPFileHelper.FileVersion);

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "longitude");
            e3.SetAttribute("val", daybuff.CurrentLocation.getLocation(0).GetLongitudeEastPositive().ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "latitude");
            e3.SetAttribute("val", daybuff.CurrentLocation.getLocation(0).GetLatitudeNorthPositive().ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "timezone");
            e3.SetAttribute("val", (daybuff.CurrentLocation.getLocation(0).getTimeZone().OffsetSeconds / 60).ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "startdate");
            e3.SetAttribute("val", daybuff.m_vcStart.ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "daycount");
            e3.SetAttribute("val", daybuff.m_vcCount.ToString());

            e3 = doc.CreateElement("arg");
            e2.AppendChild(e3);
            e3.SetAttribute("name", "dst");
            e3.SetAttribute("val", daybuff.CurrentLocation.getLocation(0).getTimeZoneName());

            e2 = doc.CreateElement("result");
            e1.AppendChild(e2);
            e2.SetAttribute("name", "Calendar");

            e3 = doc.CreateElement("dstsystem");
            e2.AppendChild(e3);
            e3.SetAttribute("name", daybuff.CurrentLocation.getLocation(0).getTimeZoneName());

            for (k = 0; k < daybuff.m_vcCount; k++)
            {
                pvd = daybuff.get(k);
                if (pvd != null)
                {
                    if (nPrevMasa != pvd.astrodata.nMasa)
                    {
                        e3 = doc.CreateElement("masa");
                        e2.AppendChild(e3);
                        e3.SetAttribute("name", GPMasa.GetName(pvd.astrodata.nMasa) + " Masa" + (nPrevMasa == GPMasa.ADHIKA_MASA ? " " + getSharedStringHtml(109) : ""));
                        e3.SetAttribute("gyear", pvd.getGaurabdaYearLongString());
                    }

                    nPrevMasa = pvd.astrodata.nMasa;

                    eday = doc.CreateElement("day");
                    e3.AppendChild(eday);
                    eday.SetAttribute("date", pvd.date.ToString());
                    eday.SetAttribute("dayweekid", pvd.date.getDayOfWeek().ToString());
                    eday.SetAttribute("dayweek", getSharedStringHtml(150 + pvd.date.getDayOfWeek()));

                    // sunrise data
                    e5 = doc.CreateElement("sunrise");
                    eday.AppendChild(e5);
                    e5.SetAttribute("time", pvd.astrodata.sun.rise.getLongTimeString());

                    e6 = doc.CreateElement("tithi");
                    e5.AppendChild(e6);
                    e6.SetAttribute("name", pvd.getTithiNameExtended());
                    e6.SetAttribute("elapse", pvd.astrodata.nTithiElapse.ToString());
                    e6.SetAttribute("index", (pvd.astrodata.nTithi % 30 + 1).ToString());

                    e6 = doc.CreateElement("naksatra");
                    e5.AppendChild(e6);
                    e6.SetAttribute("name", pvd.getNaksatraName());
                    e6.SetAttribute("elapse", pvd.astrodata.nNaksatraElapse.ToString());

                    e6 = doc.CreateElement("yoga");
                    e5.AppendChild(e6);
                    e6.SetAttribute("name", pvd.getYogaName());

                    e6 = doc.CreateElement("paksa");
                    e5.AppendChild(e6);
                    e6.SetAttribute("id", GPPaksa.getAbbreviation(pvd.astrodata.nPaksa));
                    e6.SetAttribute("name", GPPaksa.getName(pvd.astrodata.nPaksa));

                    e5 = doc.CreateElement("dst");
                    eday.AppendChild(e5);
                    e5.SetAttribute("offset", pvd.date.getDaylightTimeBias().ToString());


                    // arunodaya data
                    e5 = doc.CreateElement("arunodaya");
                    eday.AppendChild(e5);
                    e5.SetAttribute("time", pvd.astrodata.sun.arunodaya.getLongTimeString());

                    e6 = doc.CreateElement("tithi");
                    e5.AppendChild(e6);
                    e6.SetAttribute("name", GPTithi.getName(pvd.astrodata.getTithiAtArunodaya()));

                    e5 = doc.CreateElement("noon");
                    eday.AppendChild(e5);
                    e5.SetAttribute("time", pvd.astrodata.sun.noon.getLongTimeString());

                    e5 = doc.CreateElement("sunset");
                    eday.AppendChild(e5);
                    e5.SetAttribute("time", pvd.astrodata.sun.set.getLongTimeString());

                    if (pvd.hasEkadasiParana() && pvd.ekadasiParanaStart != null)
                    {
                        e5 = doc.CreateElement("parana");
                        eday.AppendChild(e5);
                        if (pvd.ekadasiParanaEnd != null)
                        {
                            e5.SetAttribute("from", pvd.ekadasiParanaStart.getShortTimeString());
                            e5.SetAttribute("to", pvd.ekadasiParanaEnd.getShortTimeString());
                        }
                        else
                        {
                            e5.SetAttribute("after", pvd.ekadasiParanaStart.getShortTimeString());
                        }
                    }
                    str = string.Empty;

                    foreach (GPCalendarDay.Festival fest in pvd.Festivals)
                    {
                        e5 = doc.CreateElement("festival");
                        eday.AppendChild(e5);
                        e5.SetAttribute("name", fest.Text);
                        e5.SetAttribute("class", fest.ShowSettingItem);
                    }

                    if (pvd.nFastType != GPConstants.FAST_NULL)
                    {
                        e5 = doc.CreateElement("fast");
                        eday.AppendChild(e5);

                        e5.SetAttribute("type", pvd.nFastType.ToString());
                        e5.SetAttribute("mark", "*");
                    }

                    if (pvd.sankranti_zodiac >= 0)
                    {
                        e5 = doc.CreateElement("sankranti");
                        eday.AppendChild(e5);
                        e5.SetAttribute("rasi", GPSankranti.getName(pvd.sankranti_zodiac));
                        e5.SetAttribute("time", pvd.sankranti_day.getLongTimeString());
                    }

                    if (pvd.hasKsayaTithi())
                    {
                        GPGregorianTime vcStart = pvd.ksayaTithi.getStartTime();
                        GPGregorianTime vcEnd   = pvd.ksayaTithi.getEndTime();

                        e5 = doc.CreateElement("ksaya");
                        eday.AppendChild(e5);
                        e5.SetAttribute("from", vcStart.ToString() + " " + vcStart.getShortTimeString());
                        e5.SetAttribute("to", vcEnd.ToString() + " " + vcEnd.getShortTimeString());
                    }


                    if (pvd.IsSecondDayTithi)
                    {
                        e5 = doc.CreateElement("vriddhi");
                        eday.AppendChild(e5);
                        e5.SetAttribute("sd", "yes");
                    }
                }
            }

            return(doc);
        }