Example #1
0
        // test if today is tithi of given masa, or day after tithi of given masa
        // while in second cas yesterday is tithi before given tithi and masa
        public bool testFestival(GCFestivalSpecialExecutor exec, bool stickToMasa)
        {
            VAISNAVADAY yesterday = exec.day(-DayOffset - 1);
            VAISNAVADAY today     = exec.day(-DayOffset);
            VAISNAVADAY tomorrow  = exec.day(-DayOffset + 1);

            if (today.astrodata.Masa == nMasa && today.astrodata.sunRise.Tithi == nTithi)
            {
                if (yesterday.astrodata.Masa == nMasa && yesterday.astrodata.sunRise.Tithi == nTithi)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            if (stickToMasa || GCMasa.IS_EXTRA(today.astrodata.Masa))
            {
                if (today.ksayaMasa == nMasa && today.ksayaTithi == nTithi)
                {
                    return(true);
                }
            }
            else
            {
                if (yesterday.ksayaMasa == nMasa && yesterday.ksayaTithi == nTithi)
                {
                    return(true);
                }
            }

            return(false);
        }
 public override void updateListBoxEntry(GCListBoxEntry lb)
 {
     base.updateListBoxEntry(lb);
     if (nMasaMax == nMasaMin)
     {
         lb.Subtitle = string.Format("Event active in {0} Masa", GCMasa.GetName(nMasaMin));
     }
     else
     {
         lb.Subtitle = string.Format("Event active from {0} to {1} Masa", GCMasa.GetName(nMasaMin),
                                     GCMasa.GetName(nMasaMax));
     }
 }
        // test if today is tithi of given masa, or day after tithi of given masa
        // while in second cas yesterday is tithi before given tithi and masa
        public bool testFestival(GCFestivalSpecialExecutor exec, bool stickToMasa)
        {
            VAISNAVADAY yesterday = exec.day(-DayOffset - 1);
            VAISNAVADAY today     = exec.day(-DayOffset);
            VAISNAVADAY tomorrow  = exec.day(-DayOffset + 1);

            if (today.astrodata.Masa == nMasa && today.astrodata.sunRise.Tithi == nTithi)
            {
                if (yesterday.astrodata.Masa == nMasa && yesterday.astrodata.sunRise.Tithi == nTithi)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            // in case tithi is ksaya, and we want to observe festival on the calendar day, when tithi is ksaya, return yes
            if (today.ksayaMasa == nMasa && today.ksayaTithi == nTithi && GCDisplaySettings.Current.AdvFestivalFirstDay)
            {
                return(true);
            }

            if (stickToMasa || GCMasa.IS_EXTRA(today.astrodata.Masa))
            {
                if (today.ksayaMasa == nMasa && today.ksayaTithi == nTithi)
                {
                    return(true);
                }
            }
            else
            {
                if (yesterday.ksayaMasa == nMasa && yesterday.ksayaTithi == nTithi && GCDisplaySettings.Current.AdvFestivalFirstDay == false)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
        public override GSCore GetPropertyValue(string s)
        {
            switch (s)
            {
            case "masa":
                return(new GSNumber(masa));

            case "masaName":
                return(new GSString(GCMasa.GetName(masa)));

            case "year":
                return(new GSNumber(year));

            case "startDate":
                return(vc_start);

            case "endDate":
                return(vc_end);

            default:
                break;
            }
            return(base.GetPropertyValue(s));
        }
        public static void Export(string pszFile, int format)
        {
            String strc;

            using (StreamWriter f = new StreamWriter(pszFile))
            {
                foreach (GCFestivalBook book in GCFestivalBookCollection.Books)
                {
                    switch (format)
                    {
                    case 1:
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("{0}\n\t{1} Tithi,{2} Paksa,{3} Masa\n", pce.Text,
                                                     GCTithi.GetName(pce.nTithi), GCPaksa.GetName(pce.nTithi / 15), GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                                if (pce.FastID != 0)
                                {
                                    strc = string.Format("\t{0}\n", GCStrings.GetFastingName(pce.FastID));
                                    f.Write(strc);
                                }
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write(string.Format("{0}\n\t\t{1} Sankranti, {2}\n", se.Text, GCRasi.GetName(se.RasiOfSun), se.DayOffset));
                            }
                        }

                        break;

                    case 2:
                    {
                        f.Write("<xml>\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t<event>\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("\t\t<name>{0}</name>\n", pce.Text);
                                f.Write(strc);
                                strc = string.Format("\t\t<tithi>{0}</tithi>\n", GCTithi.GetName(pce.nTithi));
                                f.Write(strc);
                                strc = string.Format("\t\t<paksa>{0}</paksa>\n", GCPaksa.GetName(pce.nTithi / 15));
                                f.Write(strc);
                                strc = string.Format("\t\t<masa>{0}</masa>\n", GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t<name>" + se.Text + "</name>\n");
                                f.Write("\t\t<sankranti>" + GCRasi.GetName(se.RasiOfSun) + "</sankranti>\n");
                                f.Write("\t\t<rel>" + se.DayOffset + "</rel>\n");
                            }

                            if (fb.EventsCount > 0)
                            {
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t<relatedEvent>\n");
                                        f.Write("\t\t\t<name>" + rel.Text + "</name>\n");
                                        f.Write("\t\t\t<offset>" + rel.DayOffset + "</offset>\n");
                                        f.Write("\t\t</relatedEvent>\n");
                                    }
                                }
                            }

                            f.Write("\t</event>\n");
                        }

                        f.Write("</xml>\n");
                    }
                    break;

                    case 3:
                        GSScript script = new GSScript();
                        script.Add(new GSToken("book"));
                        script.Add(new GSList(new GSToken("bookId"), new GSNumber(book.CollectionId)));
                        script.Add(new GSList(new GSToken("bookName"), new GSString(book.CollectionName)));
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            script.Add(fb.ExecuteMessage("getScript"));
                        }
                        script.writeScript(f);
                        break;

                    case 15:
                    {
                        f.Write("{\n");
                        f.Write("\tname: \"" + book.CollectionName + "\",\n");
                        f.Write("\tbookid: " + book.CollectionId + ",\n");
                        f.Write("\tevents: [\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t\t{\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                f.Write("\t\t\ttype: \"T\",\n");
                                f.Write("\t\t\tname: \"{0}\",\n", pce.Text);
                                f.Write("\t\t\ttithi: {0},\n", pce.nTithi);
                                f.Write("\t\t\tmasa: {0}\n", pce.nMasa);
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", pce.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", pce.FastID);
                                f.Write("\t\t\tstart: {0},\n", pce.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", pce.DayOffset);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t\ttype:\"S\",\n");
                                f.Write("\t\t\tname: \"" + se.Text + "\",\n");
                                f.Write("\t\t\tsankranti: " + se.RasiOfSun + ",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }
                            else if (fb is GCFestivalSpecial)
                            {
                                GCFestivalSpecial spe = fb as GCFestivalSpecial;
                                f.Write("\t\t\ttype: \"X\",\n");
                                f.Write("\t\t\tname: \"" + spe.Text + "\",\n");
                                f.Write("\t\t\tmasa1: " + spe.nMasaMin + ",\n");
                                f.Write("\t\t\tmasa2: " + spe.nMasaMax + ",\n");
                                f.Write("\t\t\tscript: \"" + spe.Script + "\",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }
                            else if (fb is GCFestivalEkadasi)
                            {
                                GCFestivalEkadasi se = fb as GCFestivalEkadasi;
                                f.Write("\t\t\ttype: \"E\",\n");
                                f.Write("\t\t\tname: \"" + se.Text + "\",\n");
                                f.Write("\t\t\tmasa: " + se.nMasa + ",\n");
                                f.Write("\t\t\tpaksa: " + se.nPaksa + ",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }

                            if (fb.EventsCount > 0)
                            {
                                f.Write("\t\t\tevents: [\n");
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t\t\t{\n\t\t\t\t\ttype:\"R\",\n");
                                        f.Write("\t\t\t\t\tname: \"" + rel.Text + "\",\n");
                                        f.Write("\t\t\t\t\tfastSubj: \"{0}\",\n", fb2.FastingSubject);
                                        f.Write("\t\t\t\t\tfast: {0},\n", fb2.FastID);
                                        f.Write("\t\t\t\t\tstart: {0},\n", fb2.StartYear);
                                        f.Write("\t\t\t\t\tdayoff: {0},\n", fb2.DayOffset);
                                        f.Write("\t\t\t\t},\n");
                                    }
                                }
                                f.Write("\t\t\t]");
                            }

                            f.Write("\t\t},\n");
                        }

                        f.Write("\t]\n");
                        f.Write("},\n");
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
 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));
 }
Example #9
0
 public override string ToString()
 {
     return(string.Format("{0}, Fast:{1}, Tithi:{2}, Masa:{3}", date.ToString(), GCStrings.GetFastingName(this.nFastID), GCTithi.GetName(this.astrodata.sunRise.Tithi),
                          GCMasa.GetName(astrodata.Masa)));
 }
Example #10
0
        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 override void updateListBoxEntry(GCListBoxEntry lb)
 {
     base.updateListBoxEntry(lb);
     lb.Subtitle = string.Format("{0} Tithi, {1} Masa", GCTithi.GetName(nTithi), GCMasa.GetName(nMasa));
 }
Example #12
0
        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 static void Export(string pszFile, int format)
        {
            String strc;

            using (StreamWriter f = new StreamWriter(pszFile))
            {
                foreach (GCFestivalBook book in GCFestivalBookCollection.Books)
                {
                    switch (format)
                    {
                    case 1:
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("{0}\n\t{1} Tithi,{2} Paksa,{3} Masa\n", pce.Text,
                                                     GCTithi.GetName(pce.nTithi), GCPaksa.GetName(pce.nTithi / 15), GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                                if (pce.FastID != 0)
                                {
                                    strc = string.Format("\t{0}\n", GCStrings.GetFastingName(pce.FastID));
                                    f.Write(strc);
                                }
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write(string.Format("{0}\n\t\t{1} Sankranti, {2}\n", se.Text, GCRasi.GetName(se.RasiOfSun), se.DayOffset));
                            }
                        }

                        break;

                    case 2:
                    {
                        f.Write("<xml>\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t<event>\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("\t\t<name>{0}</name>\n", pce.Text);
                                f.Write(strc);
                                strc = string.Format("\t\t<tithi>{0}</tithi>\n", GCTithi.GetName(pce.nTithi));
                                f.Write(strc);
                                strc = string.Format("\t\t<paksa>{0}</paksa>\n", GCPaksa.GetName(pce.nTithi / 15));
                                f.Write(strc);
                                strc = string.Format("\t\t<masa>{0}</masa>\n", GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t<name>" + se.Text + "</name>\n");
                                f.Write("\t\t<sankranti>" + GCRasi.GetName(se.RasiOfSun) + "</sankranti>\n");
                                f.Write("\t\t<rel>" + se.DayOffset + "</rel>\n");
                            }

                            if (fb.EventsCount > 0)
                            {
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t<relatedEvent>\n");
                                        f.Write("\t\t\t<name>" + rel.Text + "</name>\n");
                                        f.Write("\t\t\t<offset>" + rel.DayOffset + "</offset>\n");
                                        f.Write("\t\t</relatedEvent>\n");
                                    }
                                }
                            }

                            f.Write("\t</event>\n");
                        }

                        f.Write("</xml>\n");
                    }
                    break;

                    case 3:
                        GSScript script = new GSScript();
                        script.Add(new GSToken("book"));
                        script.Add(new GSList(new GSToken("bookId"), new GSNumber(book.CollectionId)));
                        script.Add(new GSList(new GSToken("bookName"), new GSString(book.CollectionName)));
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            script.Add(fb.ExecuteMessage("getScript"));
                        }
                        script.writeScript(f);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Example #14
0
 public override void updateListBoxEntry(GCListBoxEntry lb)
 {
     base.updateListBoxEntry(lb);
     lb.Subtitle = string.Format("Ekadasi in {0} Masa, {1} Paksa", GCMasa.GetName(nMasa), GCPaksa.GetName(nPaksa));
 }
Example #15
0
        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);
        }