Example #1
0
        private int CalculateTithis(GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCEarthData earth, GCConfigRatedEvents rec)
        {
            int nData = 0;
            GregorianDateTime vcNext;
            double            ndst;

            vcAdd.SubtractDays(1);
            while (vcAdd.IsBeforeThis(vcEnd))
            {
                nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext);
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                {
                    vcNext.InitWeekDay();
                    ndst = loc.TimeZone.GetBiasMinutesForDay(vcNext) / 60.0;
                    vcNext.AddHours(ndst);
                    //AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData, ndst);
                    AddRating(vcNext, rec.rateTithi[nData], rec.rateTithi[Prev(nData, 30)]);
                }
                else
                {
                    break;
                }
                vcAdd.Set(vcNext);
                vcAdd.shour += 0.2;
                if (vcAdd.shour >= 1.0)
                {
                    vcAdd.shour -= 1.0;
                    vcAdd.NextDay();
                }
            }
            return(nData);
        }
Example #2
0
        public override bool IsFestivalDay(GCFestivalSpecialExecutor exec)
        {
            VAISNAVADAY testDay = exec.day(-DayOffset);

            return(testDay.astrodata.Masa == nMasa &&
                   testDay.astrodata.sunRise.Paksa == nPaksa &&
                   (GCTithi.TITHI_EKADASI(testDay.astrodata.sunRise.Tithi) ||
                    GCTithi.TITHI_DVADASI(testDay.astrodata.sunRise.Tithi)) &&
                   testDay.nFastID == FastType.FAST_EKADASI);
        }
Example #3
0
        /*
         *
         * Routines for calculation begining and ending times of given Tithi
         *
         * Main function is GetTithiTimes
         *
         */

        public static double GetTithiTimes(GCEarthData ed, GregorianDateTime vc, out double titBeg, out double titEnd, double sunRise)
        {
            GregorianDateTime d1, d2;

            vc.shour = sunRise;
            GCTithi.GetPrevTithiStart(ed, vc, out d1);
            GCTithi.GetNextTithiStart(ed, vc, out d2);

            titBeg = d1.shour + d1.GetJulian() - vc.GetJulian();
            titEnd = d2.shour + d2.GetJulian() - vc.GetJulian();

            return(titEnd - titBeg);
        }
Example #4
0
        public String GetFullTithiName()
        {
            string str;

            str = GCTithi.GetName(astrodata.sunRise.Tithi);

            if (HasExtraFastingNote())
            {
                str = string.Format("{0} {1}", str, GetExtraFastingNote());
            }

            return(str);
        }
Example #5
0
        public bool NextNewFullIsVriddhi(GCEarthData earth)
        {
            int         i = 0;
            int         nTithi;
            int         nPrevTithi = 100;
            VAISNAVADAY t          = this;

            for (i = 0; i < 8 && t != null; i++)
            {
                nTithi = t.astrodata.sunRise.Tithi;
                if ((nTithi == nPrevTithi) && GCTithi.TITHI_FULLNEW_MOON(nTithi))
                {
                    return(true);
                }
                nPrevTithi = nTithi;
                t          = t.Next;
            }

            return(false);
        }
Example #6
0
        private void CalculateKsayaVriddhiTithis()
        {
            GCEarthData earth = m_Location.GetEarthData();

            foreach (VAISNAVADAY t in m_pData)
            {
                VAISNAVADAY s = t.Previous;

                if (s == null)
                {
                    continue;
                }

                if (t.astrodata.sunRise.Tithi == s.astrodata.sunRise.Tithi)
                {
                    t.vriddhiDayNo = 2;
                    if (GCDisplaySettings.Current.getValue(GCDS.CAL_VRDDHI) != 0)
                    {
                        t.AddEvent(DisplayPriorities.PRIO_KSAYA, GCDS.CAL_VRDDHI, GCStrings.getString(90));
                    }
                }
                else if (t.astrodata.sunRise.Tithi != GCTithi.NEXT_TITHI(s.astrodata.sunRise.Tithi))
                {
                    s.ksayaTithi = GCTithi.NEXT_TITHI(s.astrodata.sunRise.Tithi);
                    s.ksayaMasa  = (s.ksayaTithi == 0 ? t.astrodata.Masa : s.astrodata.Masa);
                    int    idx = 0;
                    String str;

                    List <VAISNAVADAY.CoreEventFindRec> tithiTimes = t.GetRecentCoreTimes(CoreEventType.CCTYPE_S_RISE, CoreEventType.CCTYPE_TITHI, 2);

                    if (tithiTimes.Count == 2)
                    {
                        str = t.Format(GCStrings.Localized("Kshaya tithi: {prevTithiName} — {0} to {1} ({dstSig})"),
                                       tithiTimes[0].dateTimeOfEvent.Format("{day} {monthAbr} {hour}:{minRound}"),
                                       tithiTimes[1].dateTimeOfEvent.Format("{day} {monthAbr} {hour}:{minRound}"));

                        t.AddEvent(DisplayPriorities.PRIO_KSAYA, GCDS.CAL_KSAYA, str);
                    }
                }
            }
        }
Example #7
0
        public override GSCore GetPropertyValue(string s)
        {
            switch (s)
            {
            case "nType":
                return(new GSNumber(nType));

            case "nData":
                return(new GSNumber(nType));

            case "Time":
                return(Time);

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

            case "tithiName":
                return(new GSString(GCTithi.GetName(nData)));

            case "naksatraName":
                return(new GSString(GCNaksatra.GetName(nData)));

            case "rasiName":
                return(new GSString(GCRasi.GetName(nData)));

            case "groupNameString":
                return(new GSString(GetTypeString(nType)));

            case "typeString":
                return(new GSString(GetTypeString(nType, nData)));

            case "dstSignature":
                return(new GSString(GCStrings.GetDSTSignature(nDst)));

            default:
                return(base.GetPropertyValue(s));
            }
        }
Example #8
0
        public static GregorianDateTime CalcTithiEndEx(GregorianDateTime vcStart, int GYear, int nMasa, int nPaksa, int nTithi, GCEarthData earth, out GregorianDateTime endTithi)
        {
            int i, gy, nType;
            GregorianDateTime d   = new GregorianDateTime();
            GCAstroData       day = new GCAstroData();
            int tithi;
            int counter;
            GregorianDateTime start = new GregorianDateTime(), end = new GregorianDateTime();
            //	SUNDATA sun;
            //	MOONDATA moon;
            double sunrise;

            start.shour = -1.0;
            end.shour   = -1.0;
            start.day   = start.month = start.year = -1;
            end.day     = end.month = end.year = -1;

            /*	d = GetFirstDayOfYear(earth, nGYear + 1486);
             *  d.shour = 0.5;
             *  d.TimeZone = earth.tzone;
             */
            d.Set(vcStart);

            i = 0;
            do
            {
                d.AddDays(13);
                day.DayCalc(d, earth);
                day.Masa = day.MasaCalc(d, earth);
                gy       = day.GaurabdaYear;
                i++;
            }while (((day.sunRise.Paksa != nPaksa) || (day.Masa != nMasa)) && (i <= 30));

            if (i >= 30)
            {
                d.year   = d.month = d.day = -1;
                endTithi = null;
                return(d);
            }

            // we found masa and paksa
            // now we have to find tithi
            tithi = nTithi + nPaksa * 15;

            if (day.sunRise.Tithi == tithi)
            {
                // loc1
                // find tithi juncts in this day and according to that times,
                // look in previous or next day for end and start of this tithi
                nType = 1;
            }
            else
            {
                if (day.sunRise.Tithi < tithi)
                {
                    // do increment of date until nTithi == tithi
                    //   but if nTithi > tithi
                    //       then do decrement of date
                    counter = 0;
                    while (counter < 30)
                    {
                        d.NextDay();
                        day.DayCalc(d, earth);
                        if (day.sunRise.Tithi == tithi)
                        {
                            goto cont_2;
                        }
                        if ((day.sunRise.Tithi < tithi) && (day.sunRise.Paksa != nPaksa))
                        {
                            d.PreviousDay();
                            goto cont_2;
                        }
                        if (day.sunRise.Tithi > tithi)
                        {
                            d.PreviousDay();
                            goto cont_2;
                        }
                        counter++;
                    }
                    // somewhere is error
                    d.year = d.month = d.day = 0;
                    nType  = 0;
                }
                else
                {
                    // do decrement of date until nTithi <= tithi
                    counter = 0;
                    while (counter < 30)
                    {
                        d.PreviousDay();
                        day.DayCalc(d, earth);
                        if (day.sunRise.Tithi == tithi)
                        {
                            goto cont_2;
                        }
                        if ((day.sunRise.Tithi > tithi) && (day.sunRise.Paksa != nPaksa))
                        {
                            goto cont_2;
                        }
                        if (day.sunRise.Tithi < tithi)
                        {
                            goto cont_2;
                        }
                        counter++;
                    }
                    // somewhere is error
                    d.year = d.month = d.day = 0;
                    nType  = 0;
                }
cont_2:
                if (day.sunRise.Tithi == tithi)
                {
                    // do the same as in loc1
                    nType = 1;
                }
                else
                {
                    // nTithi != tithi and nTithi < tithi
                    // but on next day is nTithi > tithi
                    // that means we will find start and the end of tithi
                    // in this very day or on next day before sunrise
                    nType = 2;
                }
            }

            // now we know the type of day-accurancy
            // nType = 0 means, that we dont found a day
            // nType = 1 means, we find day, when tithi was present at sunrise
            // nType = 2 means, we found day, when tithi started after sunrise
            //                  but ended before next sunrise
            //
            sunrise  = day.sunRise.TotalDays;
            endTithi = new GregorianDateTime();
            if (nType == 1)
            {
                GregorianDateTime d1, d2;
                d.shour = sunrise;
                GCTithi.GetPrevTithiStart(earth, d, out d1);
                //d = d1;
                //d.shour += 0.02;
                GCTithi.GetNextTithiStart(earth, d, out d2);
                endTithi.Set(d2);
                return(d1);
            }
            else if (nType == 2)
            {
                GregorianDateTime d1, d2;
                d.shour = sunrise;
                GCTithi.GetNextTithiStart(earth, d, out d1);
                d.Set(d1);
                d.shour += 0.1;
                d.NormalizeValues();
                GCTithi.GetNextTithiStart(earth, d, out d2);

                endTithi.Set(d2);
                return(d1);
            }

            // if nType == 0, then this algoritmus has some failure
            if (nType == 0)
            {
                d.year  = 0;
                d.month = 0;
                d.day   = 0;
                d.shour = 0.0;
                endTithi.Set(d);
            }
            else
            {
                d.Set(start);
                endTithi.Set(end);
            }
            return(d);
        }
        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 #10
0
        //===========================================================================
        //
        //===========================================================================

        public static void VATIMEtoVCTIME(GaurabdaDate va, out GregorianDateTime vc, GCEarthData earth)
        {
            vc = GCTithi.CalcTithiDate(va.gyear, va.masa, va.tithi / 15, va.tithi % 15, earth);
        }
Example #11
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 #12
0
        public GCConfigRatedEvents()
        {
            int i;

            for (i = 0; i < 30; i++)
            {
                rateTithi[i]         = new GCConfigRatedEntry();
                rateTithi[i].Title   = string.Format("{0} Tithi", GCTithi.GetName(i));
                rateTithi[i].Key     = "Tithi";
                rateMuhurta[i]       = new GCConfigRatedEntry();
                rateMuhurta[i].Title = GCStrings.GetMuhurtaName(i);
                rateMuhurta[i].Key   = "Muhurta";
            }

            for (i = 0; i < 4; i++)
            {
                rateDayHours[i]       = new GCConfigRatedEntry();
                rateDayHours[i].Title = GCStrings.GetSandhyaName(i);
                rateDayHours[i].Key   = "DayHours";
            }

            for (i = 0; i < 2; i++)
            {
                rateDay[i]            = new GCConfigRatedEntry();
                rateDay[i].Title      = GCStrings.GetSandhyaName(i * 2);
                rateDay[i].Key        = "DayPart";
                rateMoonTime[i]       = new GCConfigRatedEntry();
                rateMoonTime[i].Title = GCStrings.GetMoonTimesName(i);
                rateMoonTime[i].Key   = "MoonTimes";
            }

            rateKalas[0] = new GCConfigRatedEntry();
            for (i = 1; i < 6; i++)
            {
                rateKalas[i]       = new GCConfigRatedEntry();
                rateKalas[i].Title = GCStrings.GetKalaName(i);
                rateKalas[i].Key   = string.Format("kala.{0}", i);
            }

            for (i = 0; i < 27; i++)
            {
                rateNaksatra[i]       = new GCConfigRatedEntry();
                rateNaksatra[i].Title = string.Format("{0} Naksatra", GCNaksatra.GetName(i));
                rateNaksatra[i].Key   = "Naksatra";
                rateYoga[i]           = new GCConfigRatedEntry();
                rateYoga[i].Title     = string.Format("{0} Yoga", GCYoga.GetName(i));
                rateYoga[i].Key       = "Yoga";
                for (int j = 0; j < 4; j++)
                {
                    rateNaksatraPada[i, j]       = new GCConfigRatedEntry();
                    rateNaksatraPada[i, j].Title = string.Format("{0} of {1}", GCNaksatra.GetPadaText(j), rateNaksatra[i].Title);
                    rateNaksatraPada[i, j].Key   = "NaksatraPada";
                }
            }

            for (i = 0; i < 7; i++)
            {
                weekday[i]       = new GCConfigRatedEntry();
                weekday[i].Title = string.Format("Weekday: {0}", GCCalendar.GetWeekdayName(i));
                weekday[i].Key   = "Weekday";
            }

            for (i = 0; i < 10; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    rateGrahaRasi[i, j]        = new GCConfigRatedEntry();
                    rateGrahaRasi[i, j].Title  = string.Format("{0} in {1}", GCStrings.GetPlanetNameEn(i), GCRasi.GetNameEn(j));
                    rateGrahaRasi[i, j].Key    = "RasiGraha." + GCStrings.GetPlanetNameEn(i);
                    rateGrahaHouse[i, j]       = new GCConfigRatedEntry();
                    rateGrahaHouse[i, j].Title = string.Format("{0} in house {1}", GCStrings.GetPlanetNameEn(i), j + 1);
                    rateGrahaHouse[i, j].Key   = "HouseGraha." + GCStrings.GetPlanetNameEn(i);

                    rateRasiGraha[j, i]  = rateGrahaRasi[i, j];
                    rateHouseGraha[j, i] = rateGrahaHouse[i, j];
                }
            }

            FileName = null;
        }
Example #13
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++;
            }
        }
Example #14
0
        public int MahadvadasiCalc(GCEarthData earth)
        {
            VAISNAVADAY t = this;

            if (t.Previous == null || t.Next == null)
            {
                return(0);
            }

            int nMahaType = MahadvadasiType.EV_NULL;
            //int nMhdDay = -1;

            VAISNAVADAY s       = t.Previous;
            VAISNAVADAY u       = t.Next;
            VAISNAVADAY mahaDay = null;

            // if yesterday is dvadasi
            // then we skip this day
            if (GCTithi.TITHI_DVADASI(s.astrodata.sunRise.Tithi))
            {
                return(1);
            }

            if (TithiId.TITHI_GAURA_DVADASI == t.astrodata.sunRise.Tithi && TithiId.TITHI_GAURA_DVADASI == t.astrodata.sunSet.Tithi && t.IsMhd58(out nMahaType))
            {
                t.nMahadvadasiID = nMahaType;
                mahaDay          = t;
            }
            else if (GCTithi.TITHI_DVADASI(t.astrodata.sunRise.Tithi))
            {
                if (GCTithi.TITHI_DVADASI(u.astrodata.sunRise.Tithi) && GCTithi.TITHI_EKADASI(s.astrodata.sunRise.Tithi) && GCTithi.TITHI_EKADASI(s.astrodata.sunArunodaya.Tithi))
                {
                    t.nMahadvadasiID = MahadvadasiType.EV_VYANJULI;
                    mahaDay          = t;
                }
                else if (t.NextNewFullIsVriddhi(earth))
                {
                    t.nMahadvadasiID = MahadvadasiType.EV_PAKSAVARDHINI;
                    mahaDay          = t;
                }
                else if (GCTithi.TITHI_LESS_EKADASI(s.astrodata.sunArunodaya.Tithi))
                {
                    t.nMahadvadasiID = MahadvadasiType.EV_SUDDHA;
                    mahaDay          = t;
                }
            }

            if (mahaDay != null && mahaDay.Next != null)
            {
                // fasting day
                mahaDay.nFastID            = FastType.FAST_EKADASI;
                mahaDay.ekadasi_vrata_name = GCEkadasi.GetEkadasiName(t.astrodata.Masa, t.astrodata.sunRise.Paksa);
                mahaDay.ekadasi_parana     = false;
                mahaDay.eparana_time1      = null;
                mahaDay.eparana_time2      = null;

                // parana day
                mahaDay.Next.nFastID        = FastType.FAST_NULL;
                mahaDay.Next.ekadasi_parana = true;
                mahaDay.Next.eparana_time1  = null;
                mahaDay.Next.eparana_time2  = null;
            }

            return(1);
        }
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);
        }
        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 #17
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 #18
0
        public static int writeXml(string fileName, GCLocation loc, GregorianDateTime vc)
        {
            String            str;
            GregorianDateTime date;

            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");
                xml.Write("\t\t<arg name=\"startdate\" val=\"");
                xml.Write(vc);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Tithi\">\n");

                GregorianDateTime d = new GregorianDateTime();
                d.Set(vc);
                GregorianDateTime d1, d2;
                d.TimezoneHours = loc.OffsetUtcHours;
                GregorianDateTime dn;
                GCHourTime        dt    = new GCHourTime();
                GCEarthData       earth = loc.GetEarthData();


                GCAstroData day = new GCAstroData();

                day.DayCalc(vc, earth);

                d.shour = day.sunRise.TotalDays;

                GCTithi.GetPrevTithiStart(earth, d, out d1);
                GCTithi.GetNextTithiStart(earth, d, out d2);

                {
                    dt.SetDegTime(d1.shour * 360);
                    // start tithi at t[0]
                    xml.Write("\t\t<tithi\n\t\t\tid=\"");
                    xml.Write(day.sunRise.Tithi);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tname=\"");
                    xml.Write(GCTithi.GetName(day.sunRise.Tithi));
                    xml.Write("\"\n");
                    xml.Write("\t\t\tstartdate=\"");
                    xml.Write(d1);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tstarttime=\"");
                    xml.Write(dt);
                    xml.Write("\"\n");

                    dt.SetDegTime(d2.shour * 360);
                    xml.Write("\t\t\tenddate=\"");
                    xml.Write(d2);
                    xml.Write("\"\n");
                    xml.Write("\t\t\tendtime=\"");
                    xml.Write(dt);
                    xml.Write("\"\n />");
                }

                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }
            return(1);
        }
Example #19
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));
            }
        }
Example #20
0
        public static string GetTypeString(int nType, int nData)
        {
            switch (nType)
            {
            case CoreEventType.CCTYPE_ASCENDENT:
                return("Ascendent " + GCRasi.GetName(nData));

            case CoreEventType.CCTYPE_CONJ:
                return("Conjunction in " + GCRasi.GetName(nData));

            case CoreEventType.CCTYPE_DATE:
                return("Date");

            case CoreEventType.CCTYPE_DAY_MUHURTA:
                return(string.Format("{0} Muhurta", GCStrings.GetMuhurtaName(nData)));

            case CoreEventType.CCTYPE_DAY_OF_WEEK:
                return(GCCalendar.GetWeekdayName(nData));

            case CoreEventType.CCTYPE_KALA_END:
                return(string.Format("{0} ends", GCStrings.GetKalaName(nData)));

            case CoreEventType.CCTYPE_KALA_START:
                return(string.Format("{0} starts", GCStrings.GetKalaName(nData)));

            case CoreEventType.CCTYPE_M_RASI:
                return(string.Format("Moon in {0} rasi", GCRasi.GetName(nData)));

            case CoreEventType.CCTYPE_M_RISE:
                return("Moon rise");

            case CoreEventType.CCTYPE_M_SET:
                return("Moon set");

            case CoreEventType.CCTYPE_NAKS:
                return(string.Format("{0} Naksatra", GCNaksatra.GetName(nData)));

            case CoreEventType.CCTYPE_S_ARUN:
                return("Arunodaya");

            case CoreEventType.CCTYPE_S_MIDNIGHT:
                return("Midnight");

            case CoreEventType.CCTYPE_S_NOON:
                return("Noon");

            case CoreEventType.CCTYPE_S_RISE:
                return("Sunrise");

            case CoreEventType.CCTYPE_S_SET:
                return("Sunset");

            case CoreEventType.CCTYPE_SANK:
                return(string.Format("{0} Sankranti", GCRasi.GetName(nData)));

            case CoreEventType.CCTYPE_TITHI:
                return(string.Format("{0} Tithi", GCTithi.GetName(nData)));

            case CoreEventType.CCTYPE_YOGA:
                return(string.Format("{0} Yoga", GCYoga.GetName(nData)));

            default:
                return(string.Format("Unspecified event {0} / {1}", nType, nData));
            }
        }
Example #21
0
        public void CalculateEvents(GCLocation loc, GregorianDateTime vcStart, GregorianDateTime vcEnd)
        {
            //GCSunData sun = new GCSunData();
            DstTypeChange ndst = 0;
            int           nData;

            TResultEvents inEvents = this;

            this.Clear();
            this.EarthLocation = loc;
            this.StartDateTime = new GregorianDateTime(vcStart);
            this.EndDateTime   = new GregorianDateTime(vcEnd);

            GregorianDateTime vc = new GregorianDateTime();
            GregorianDateTime vcAdd = new GregorianDateTime(), vcNext = new GregorianDateTime();
            GCEarthData       earth = loc.GetEarthData();

            vc.Set(vcStart);
            vc.TimezoneHours = loc.OffsetUtcHours;
            vcAdd.Set(vc);
            vcAdd.InitWeekDay();

            GCHourTime sunriseData, sunsetData;
            double     sunRise, sunSet;
            double     r1, r2;

            while (vcAdd.IsBeforeThis(vcEnd))
            {
                sunriseData = GCSunData.CalcSunrise(vcAdd, earth);
                sunsetData  = GCSunData.CalcSunset(vcAdd, earth);
                sunRise     = sunriseData.TotalDays;
                sunSet      = sunsetData.TotalDays;
                ndst        = loc.TimeZone.DetermineDaylightChange(vcAdd);

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SUN) != 0)
                {
                    ndst = loc.TimeZone.DetermineDaylightChange(vcAdd);

                    vcAdd.shour = sunriseData.TotalDays - 96.0 / 1440.0;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_ARUN, 0, ndst);

                    vcAdd.shour = sunRise;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_RISE, 0, ndst);

                    vcAdd.shour = (sunRise + sunSet) / 2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_NOON, 0, ndst);

                    vcAdd.shour = sunSet;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_S_SET, 0, ndst);
                }

                /*if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
                 * {
                 *  todayLongitude = sun.longitude_deg;
                 *  vcAdd.shour = sunRise;
                 *  todaySunriseHour = sunRise;
                 *  if (previousLongitude < -10)
                 *  {
                 *      GregorianDateTime prevSunrise = new GregorianDateTime();
                 *      prevSunrise.Set(vcAdd);
                 *      prevSunrise.PreviousDay();
                 *      sun.SunCalc(prevSunrise, earth);
                 *      previousSunriseHour = sun.rise.GetDayTime() - 1;
                 *      previousLongitude = sun.longitude_deg;
                 *      fromTimeLimit = 0;
                 *  }
                 *
                 *  double a, b;
                 *  double jd = vcAdd.GetJulianComplete();
                 *  double ayan = GCAyanamsha.GetAyanamsa(jd);
                 *  r1 = GCMath.putIn360(previousLongitude - ayan) / 30;
                 *  r2 = GCMath.putIn360(todayLongitude - ayan) / 30;
                 *
                 *  while (r2 > r1 + 13)
                 *  {
                 *      r2 -= 12.0;
                 *  }
                 *  while (r2 < r1 + 11)
                 *  {
                 *      r2 += 12.0;
                 *  }
                 *
                 *  a = (r2 - r1) / (todaySunriseHour - previousSunriseHour);
                 *  b = r2 - a * todaySunriseHour;
                 *
                 *  for (double tr = Math.Floor(r1) + 1.0; tr < r2; tr += 1.0)
                 *  {
                 *      double tm = (tr - b) / a;
                 *      if (tm > fromTimeLimit)
                 *      {
                 *          vcNext.Set(vcAdd);
                 *          vcNext.shour = tm;
                 *          vcNext.NormalizeValues();
                 *          inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_ASCENDENT, (int)tr, ndst);
                 *      }
                 *  }
                 *
                 *  previousLongitude = todayLongitude;
                 *  previousSunriseHour = todaySunriseHour - 1;
                 *  fromTimeLimit = previousSunriseHour;
                 * }*/

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_RAHUKALAM) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_RAHU_KALAM);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_RAHU_KALAM, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_RAHU_KALAM, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YAMAGHANTI) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_YAMA_GHANTI);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_YAMA_GHANTI, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_YAMA_GHANTI, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_GULIKALAM) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_GULI_KALAM);

                    vcAdd.shour = r1;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_GULI_KALAM, ndst);

                    vcAdd.shour = r2;
                    inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_GULI_KALAM, ndst);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ABHIJIT_MUHURTA) != 0)
                {
                    GCSunData.CalculateKala(sunRise, sunSet, vcAdd.dayOfWeek, out r1, out r2, KalaType.KT_ABHIJIT);

                    if (r1 > 0 && r2 > 0)
                    {
                        vcAdd.shour = r1;
                        inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_START, KalaType.KT_ABHIJIT, ndst);

                        vcAdd.shour = r2;
                        inEvents.AddEvent(vcAdd, CoreEventType.CCTYPE_KALA_END, KalaType.KT_ABHIJIT, ndst);
                    }
                }

                vcAdd.NextDay();
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
            {
                GCAscendant asc = new GCAscendant();
                asc.Earth           = EarthLocation.GetEarthData();
                asc.CurrentDateTime = new GregorianDateTime(vc);
                while (asc.GetNextAscendantBefore(vcEnd))
                {
                    ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                    inEvents.AddEvent(asc.CurrentDateTime, CoreEventType.CCTYPE_ASCENDENT, asc.CurrentSign, ndst);
                    asc.CurrentDateTime.AddHours(0.5);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_TITHI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_NAKSATRA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YOGA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SANKRANTI) != 0)
            {
                vcNext = new GregorianDateTime();
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData));
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOONRASI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCMoonData.GetNextMoonRasi(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RASI, nData, ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.5;
                    vcAdd.NormalizeValues();
                }
            }
            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_CONJUNCTION) != 0)
            {
                double dlong;
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    dlong = GCConjunction.GetNextConjunction(vcAdd, out vcNext, true, earth);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_CONJ, GCRasi.GetRasi(dlong, GCAyanamsha.GetAyanamsa(vcNext.GetJulianComplete())), ndst);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOON) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCMoonData.GetNextRise(earth, vcAdd, true));
                    inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RISE, 0, ndst);

                    vcNext.Set(GCMoonData.GetNextRise(earth, vcNext, false));
                    inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_SET, 0, ndst);

                    vcNext.shour += 0.05;
                    vcNext.NormalizeValues();
                    vcAdd.Set(vcNext);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_ASCENDENT) != 0)
            {/*
              *         vcAdd = vc;
              *         vcAdd.shour = 0.0;
              *         while(vcAdd.IsBeforeThis(vcEnd))
              *         {
              *                 nData = earth.GetNextAscendentStart(vcAdd, vcNext);
              *                 if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
              *                 {
              *                         vcNext.InitWeekDay();
              *                         ndst = TTimeZone.determineDaylightChange(vcNext, loc.m_nDST);
              *                         inEvents.AddEvent(vcNext, CCTYPE_ASCENDENT, nData, ndst);
              *                 }
              *                 else
              *                 {
              *                         break;
              *                 }
              *                 vcAdd = vcNext;
              *                 vcAdd.shour += 1/24.0;
              *                 if (vcAdd.shour >= 1.0)
              *                 {
              *                         vcAdd.shour -= 1.0;
              *                         vcAdd.NextDay();
              *                 }
              *         }
              *
              */
            }

            if (GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SORT) != 0)
            {
                inEvents.Sort(SORTING_BY_DATE);
            }
            else
            {
                inEvents.Sort(SORTING_BY_TYPE);
            }
        }
 public override void updateListBoxEntry(GCListBoxEntry lb)
 {
     base.updateListBoxEntry(lb);
     lb.Subtitle = string.Format("{0} Tithi, {1} Masa", GCTithi.GetName(nTithi), GCMasa.GetName(nMasa));
 }
Example #23
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 #24
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 #25
0
        public int EkadasiCalc(GCEarthData earth)
        {
            VAISNAVADAY t = this;

            if (t.Previous == null || t.Next == null)
            {
                return(0);
            }

            VAISNAVADAY s = t.Previous;
            VAISNAVADAY u = t.Next;

            if (GCTithi.TITHI_EKADASI(t.astrodata.sunRise.Tithi))
            {
                // if TAT < 11 then NOT_EKADASI
                if (GCTithi.TITHI_LESS_EKADASI(t.astrodata.sunArunodaya.Tithi))
                {
                    t.nMahadvadasiID     = MahadvadasiType.EV_NULL;
                    t.ekadasi_vrata_name = "";
                    t.nFastID            = FastType.FAST_NULL;
                }
                else
                {
                    // else ak MD13 then MHD1 and/or 3
                    if (GCTithi.TITHI_EKADASI(s.astrodata.sunRise.Tithi) && GCTithi.TITHI_EKADASI(s.astrodata.sunArunodaya.Tithi))
                    {
                        if (GCTithi.TITHI_TRAYODASI(u.astrodata.sunRise.Tithi))
                        {
                            t.nMahadvadasiID     = MahadvadasiType.EV_UNMILANI_TRISPRSA;
                            t.ekadasi_vrata_name = GCEkadasi.GetEkadasiName(t.astrodata.Masa, t.astrodata.sunRise.Paksa);
                            t.nFastID            = FastType.FAST_EKADASI;
                        }
                        else
                        {
                            t.nMahadvadasiID     = MahadvadasiType.EV_UNMILANI;
                            t.ekadasi_vrata_name = GCEkadasi.GetEkadasiName(t.astrodata.Masa, t.astrodata.sunRise.Paksa);
                            t.nFastID            = FastType.FAST_EKADASI;
                        }
                    }
                    else
                    {
                        if (GCTithi.TITHI_TRAYODASI(u.astrodata.sunRise.Tithi))
                        {
                            t.nMahadvadasiID     = MahadvadasiType.EV_TRISPRSA;
                            t.ekadasi_vrata_name = GCEkadasi.GetEkadasiName(t.astrodata.Masa, t.astrodata.sunRise.Paksa);
                            t.nFastID            = FastType.FAST_EKADASI;
                        }
                        else
                        {
                            // else ak U je MAHADVADASI then NOT_EKADASI
                            if (GCTithi.TITHI_EKADASI(u.astrodata.sunRise.Tithi) || (u.nMahadvadasiID >= MahadvadasiType.EV_SUDDHA))
                            {
                                t.nMahadvadasiID     = MahadvadasiType.EV_NULL;
                                t.ekadasi_vrata_name = "";
                                t.nFastID            = FastType.FAST_NULL;
                            }
                            else if (u.nMahadvadasiID == MahadvadasiType.EV_NULL)
                            {
                                // else suddha ekadasi
                                t.nMahadvadasiID     = MahadvadasiType.EV_SUDDHA;
                                t.ekadasi_vrata_name = GCEkadasi.GetEkadasiName(t.astrodata.Masa, t.astrodata.sunRise.Paksa);
                                t.nFastID            = FastType.FAST_EKADASI;
                            }
                        }
                    }
                }
            }
            // test for break fast


            return(1);
        }
Example #26
0
        /*
         * Function before is writen accoring this algorithms:
         *
         *
         *  1. Normal - fasting day has ekadasi at sunrise and dvadasi at next sunrise.
         *
         *  2. Viddha - fasting day has dvadasi at sunrise and trayodasi at next
         *  sunrise, and it is not a naksatra mahadvadasi
         *
         *  3. Unmilani - fasting day has ekadasi at both sunrises
         *
         *  4. Vyanjuli - fasting day has dvadasi at both sunrises, and it is not a
         *  naksatra mahadvadasi
         *
         *  5. Trisprsa - fasting day has ekadasi at sunrise and trayodasi at next
         *  sunrise.
         *
         *  6. Jayanti/Vijaya - fasting day has gaura dvadasi and specified naksatra at
         *  sunrise and same naksatra at next sunrise
         *
         *  7. Jaya/Papanasini - fasting day has gaura dvadasi and specified naksatra at
         *  sunrise and same naksatra at next sunrise
         *
         *  ==============================================
         *  Case 1 Normal (no change)
         *
         *  If dvadasi tithi ends before 1/3 of daylight
         *     then PARANA END = TIME OF END OF TITHI
         *  but if dvadasi TITHI ends after 1/3 of daylight
         *     then PARANA END = TIME OF 1/3 OF DAYLIGHT
         *
         *  if 1/4 of dvadasi tithi is before sunrise
         *     then PARANA BEGIN is sunrise time
         *  but if 1/4 of dvadasi tithi is after sunrise
         *     then PARANA BEGIN is time of 1/4 of dvadasi tithi
         *
         *  if PARANA BEGIN is before PARANA END
         *     then we will write "BREAK FAST FROM xx TO yy
         *  but if PARANA BEGIN is after PARANA END
         *     then we will write "BREAK FAST AFTER xx"
         *
         *  ==============================================
         *  Case 2 Viddha
         *
         *  If trayodasi tithi ends before 1/3 of daylight
         *     then PARANA END = TIME OF END OF TITHI
         *  but if trayodasi TITHI ends after 1/3 of daylight
         *     then PARANA END = TIME OF 1/3 OF DAYLIGHT
         *
         *  PARANA BEGIN is sunrise time
         *
         *  we will write "BREAK FAST FROM xx TO yy
         *
         *  ==============================================
         *  Case 3 Unmilani
         *
         *  PARANA END = TIME OF 1/3 OF DAYLIGHT
         *
         *  PARANA BEGIN is end of Ekadasi tithi
         *
         *  if PARANA BEGIN is before PARANA END
         *     then we will write "BREAK FAST FROM xx TO yy
         *  but if PARANA BEGIN is after PARANA END
         *     then we will write "BREAK FAST AFTER xx"
         *
         *  ==============================================
         *  Case 4 Vyanjuli
         *
         *  PARANA BEGIN = Sunrise
         *
         *  PARANA END is end of Dvadasi tithi
         *
         *  we will write "BREAK FAST FROM xx TO yy
         *
         *  ==============================================
         *  Case 5 Trisprsa
         *
         *  PARANA BEGIN = Sunrise
         *
         *  PARANA END = 1/3 of daylight hours
         *
         *  we will write "BREAK FAST FROM xx TO yy
         *
         *  ==============================================
         *  Case 6 Jayanti/Vijaya
         *
         *  PARANA BEGIN = Sunrise
         *
         *  PARANA END1 = end of dvadasi tithi or sunrise, whichever is later
         *  PARANA END2 = end of naksatra
         *
         *  PARANA END is earlier of END1 and END2
         *
         *  we will write "BREAK FAST FROM xx TO yy
         *
         *  ==============================================
         *  Case 7 Jaya/Papanasini
         *
         *  PARANA BEGIN = end of naksatra
         *
         *  PARANA END = 1/3 of Daylight hours
         *
         *  if PARANA BEGIN is before PARANA END
         *     then we will write "BREAK FAST FROM xx TO yy
         *  but if PARANA BEGIN is after PARANA END
         *     then we will write "BREAK FAST AFTER xx"
         *
         *
         * */
        public int CalculateEParana(GCEarthData earth)
        {
            VAISNAVADAY t = this;

            if (t.Previous == null)
            {
                return(0);
            }

            t.nMahadvadasiID = MahadvadasiType.EV_NULL;
            t.ekadasi_parana = true;
            t.nFastID        = FastType.FAST_NULL;

            TCoreEvent naksEnd;
            TCoreEvent parBeg     = null;
            TCoreEvent parEnd     = null;
            TCoreEvent tithiStart = null;
            TCoreEvent tithiEnd   = null;
            TCoreEvent sunRise    = t.FindCoreEvent(CoreEventType.CCTYPE_S_RISE);
            TCoreEvent sunSet     = t.FindCoreEvent(CoreEventType.CCTYPE_S_SET);

            if (sunRise == null || sunSet == null)
            {
                GCLog.Write("Cannot find sunrise of sunset for day " + t.date.ToString());
                return(0);
            }

            TCoreEvent third_day = new TCoreEvent()
            {
                nData = sunRise.nData,
                nType = CoreEventType.CCTYPE_THIRD_OF_DAY,
                nDst  = sunRise.nDst,
                Time  = (sunSet.Time - sunRise.Time) / 3 + sunRise.Time
            };

            List <CoreEventFindRec> tempTimes = GetRecentCoreTimes(CoreEventType.CCTYPE_S_RISE, CoreEventType.CCTYPE_TITHI, 1);

            if (tempTimes.Count != 1)
            {
                GCLog.Write("Start or End of tithi was not found for date " + t.ToString());
                return(0);
            }
            else
            {
                tithiStart = tempTimes[0].coreEvent;
            }

            tempTimes = GetNextCoreTimes(CoreEventType.CCTYPE_S_RISE, CoreEventType.CCTYPE_TITHI, 1);
            if (tempTimes.Count != 1)
            {
                GCLog.Write("End of tithi was not found for date " + t.ToString());
                tempTimes = GetNextCoreTimes(CoreEventType.CCTYPE_S_RISE, CoreEventType.CCTYPE_TITHI, 1);
                return(0);
            }
            else
            {
                tithiEnd = new TCoreEvent(tempTimes[0].coreEvent)
                {
                    nType = CoreEventType.CCTYPE_TITHI_END
                };
                tithiEnd.ApplyDstType(UtcDayStart, DstDayType);
            }

            if (Previous == null)
            {
                return(0);
            }

            tempTimes = Previous.GetNextCoreTimes(CoreEventType.CCTYPE_S_RISE, CoreEventType.CCTYPE_NAKS, 1);
            if (tempTimes.Count != 1)
            {
                GCLog.Write("End of naksatra was not found for date " + t.ToString());
                return(0);
            }
            else
            {
                naksEnd = new TCoreEvent(tempTimes[0].coreEvent)
                {
                    nType = CoreEventType.CCTYPE_NAKS_END
                };
                naksEnd.ApplyDstType(UtcDayStart, DstDayType);
            }

            TCoreEvent tithi_quart = new TCoreEvent()
            {
                nType = CoreEventType.CCTYPE_TITHI_QUARTER,
                nData = tithiStart.nData,
                Time  = (tithiEnd.Time - tithiStart.Time) / 4 + tithiStart.Time,
                nDst  = tithiStart.nDst
            };

            tithi_quart.ApplyDstType(UtcDayStart, DstDayType);


            switch (t.Previous.nMahadvadasiID)
            {
            case MahadvadasiType.EV_UNMILANI:
                parEnd = GCMath.Min(tithiEnd, third_day);
                parBeg = sunRise;
                break;

            case MahadvadasiType.EV_VYANJULI:
                parBeg = sunRise;
                parEnd = GCMath.Min(tithiEnd, third_day);
                break;

            case MahadvadasiType.EV_TRISPRSA:
                parBeg = sunRise;
                parEnd = third_day;
                break;

            case MahadvadasiType.EV_JAYANTI:
            case MahadvadasiType.EV_VIJAYA:
                if (GCTithi.TITHI_DVADASI(t.astrodata.sunRise.Tithi))
                {
                    if (naksEnd.Time < tithiEnd.Time)
                    {
                        if (naksEnd.Time < third_day.Time)
                        {
                            parBeg = naksEnd;
                            parEnd = GCMath.Min(tithiEnd, third_day);
                        }
                        else
                        {
                            parBeg = naksEnd;
                            parEnd = tithiEnd;
                        }
                    }
                    else
                    {
                        parBeg = sunRise;
                        parEnd = GCMath.Min(tithiEnd, third_day);
                    }
                }
                else
                {
                    parBeg = sunRise;
                    parEnd = GCMath.Min(naksEnd, third_day);
                }

                break;

            case MahadvadasiType.EV_JAYA:
            case MahadvadasiType.EV_PAPA_NASINI:
                if (GCTithi.TITHI_DVADASI(t.astrodata.sunRise.Tithi))
                {
                    if (naksEnd.Time < tithiEnd.Time)
                    {
                        if (naksEnd.Time < third_day.Time)
                        {
                            parBeg = naksEnd;
                            parEnd = GCMath.Min(tithiEnd, third_day);
                        }
                        else
                        {
                            parBeg = naksEnd;
                            parEnd = tithiEnd;
                        }
                    }
                    else
                    {
                        parBeg = sunRise;
                        parEnd = GCMath.Min(tithiEnd, third_day);
                    }
                }
                else
                {
                    if (naksEnd.Time < third_day.Time)
                    {
                        parBeg = naksEnd;
                        parEnd = third_day;
                    }
                    else
                    {
                        parBeg = naksEnd;
                        parEnd = null;
                    }
                }

                break;

            default:
                // first initial
                parEnd = GCMath.Min(tithiEnd, third_day);
                parBeg = GCMath.Max(sunRise, tithi_quart);
                if (GCTithi.TITHI_DVADASI(t.Previous.astrodata.sunRise.Tithi))
                {
                    parBeg = sunRise;
                }

                break;
            }

            if (parBeg.Time >= parEnd.Time)
            {
                parEnd = null;
            }

            t.eparana_time1 = parBeg;
            t.eparana_time2 = parEnd;

            return(1);
        }
        public void CalculateEvents(GCLocation loc, int nYear)
        {
            //GCSunData sun = new GCSunData();
            //DstTypeChange ndst = DstTypeChange.DstOff;
            int nData;

            TResultCoreEvents inEvents = this;

            this.Clear();
            this.EarthLocation = loc;
            this.Year          = nYear;
            GregorianDateTime vcStart = new GregorianDateTime(Year - 1, 12, 29);
            GregorianDateTime vcEnd   = new GregorianDateTime(Year + 1, 1, 2);

            GregorianDateTime vc = new GregorianDateTime();
            GregorianDateTime vcAdd = new GregorianDateTime(), vcNext = new GregorianDateTime();
            GCEarthData       earth = loc.GetEarthData();

            vc.Set(vcStart);
            vc.TimezoneHours = loc.OffsetUtcHours;
            vcAdd.Set(vc);
            vcAdd.InitWeekDay();

            /*while (vcAdd.IsBeforeThis(vcEnd))
             * {
             *  ndst = loc.TimeZone.DetermineDaylightChange(vcAdd);
             *  vcAdd.NextDay();
             * }*/


            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_TITHI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCTithi.GetNextTithiStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_TITHI, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_NAKSATRA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCNaksatra.GetNextNaksatra(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_NAKS, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_YOGA) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.2;
                    if (vcAdd.shour >= 1.0)
                    {
                        vcAdd.shour -= 1.0;
                        vcAdd.NextDay();
                    }
                }
            }

            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_SANKRANTI) != 0)
            {
                vcNext = new GregorianDateTime();
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData));
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_MOONRASI) != 0)
            {
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    nData = GCMoonData.GetNextMoonRasi(earth, vcAdd, out vcNext);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        //vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_M_RASI, nData);
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.shour += 0.5;
                    vcAdd.NormalizeValues();
                }
            }
            if (Full || GCDisplaySettings.Current.getValue(GCDS.COREEVENTS_CONJUNCTION) != 0)
            {
                double dlong;
                vcAdd.Set(vc);
                vcAdd.shour = 0.0;
                while (vcAdd.IsBeforeThis(vcEnd))
                {
                    dlong = GCConjunction.GetNextConjunction(vcAdd, out vcNext, true, earth);
                    if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                    {
                        vcNext.InitWeekDay();
                        //ndst = loc.TimeZone.DetermineDaylightChange(vcNext);
                        inEvents.AddEvent(vcNext, CoreEventType.CCTYPE_CONJ, GCRasi.GetRasi(dlong, GCAyanamsha.GetAyanamsa(vcNext.GetJulianComplete())));
                    }
                    else
                    {
                        break;
                    }
                    vcAdd.Set(vcNext);
                    vcAdd.NextDay();
                }
            }

            inEvents.Sort();
        }
Example #28
0
        /*********************************************************************/
        /*   Finds first day of given masa and gaurabda year                 */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public static GregorianDateTime GetFirstDayOfMasa(GCEarthData earth, int GYear, int nMasa)
        {
            return(GCTithi.CalcTithiDate(GYear, nMasa, 0, 0, earth));
        }