예제 #1
0
        public double GetPlanetHouse(double longitudeTropical, double julianDate, GCEarthData earth)
        {
            double longitudeSidereal = longitudeTropical - GCAyanamsha.GetAyanamsa(julianDate);
            double firstHouseStart   = earth.GetAscendantDegrees(julianDate) - 15.0;

            return(GCMath.putIn360(longitudeSidereal - firstHouseStart) / 30.0);
        }
예제 #2
0
        public static int GetNextYogaStart(GCEarthData ed, GregorianDateTime startDate, out GregorianDateTime nextDate)
        {
            double            phi = 40.0 / 3.0;
            double            l1, l2, longitudeSun;
            double            jday = startDate.GetJulianComplete();
            double            xj;
            double            longitudeMoon;
            GregorianDateTime d = new GregorianDateTime();

            d.Set(startDate);
            GregorianDateTime xd        = new GregorianDateTime();
            double            scan_step = 0.5;
            int    prev_tit             = 0;
            int    new_tit   = -1;
            double ayanamsha = GCAyanamsha.GetAyanamsa(jday);

            longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
            longitudeSun  = GCCoreAstronomy.GetSunLongitude(d, ed);
            l1            = GCMath.putIn360(longitudeMoon + longitudeSun - 2 * ayanamsha);
            prev_tit      = Convert.ToInt32(Math.Floor(l1 / phi));

            int counter = 0;

            while (counter < 20)
            {
                xj = jday;
                xd.Set(d);

                jday    += scan_step;
                d.shour += scan_step;
                if (d.shour > 1.0)
                {
                    d.shour -= 1.0;
                    d.NextDay();
                }

                longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
                longitudeSun  = GCCoreAstronomy.GetSunLongitude(d, ed);
                l2            = GCMath.putIn360(longitudeMoon + longitudeSun - 2 * ayanamsha);
                new_tit       = Convert.ToInt32(Math.Floor(l2 / phi));

                if (prev_tit != new_tit)
                {
                    jday = xj;
                    d.Set(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }
            nextDate = d;

            return(new_tit);
        }
예제 #3
0
        public static int GetNextMoonRasi(GCEarthData ed, GregorianDateTime startDate, out GregorianDateTime nextDate)
        {
            double            phi = 30.0;
            double            l1, l2, longitudeMoon;
            double            jday = startDate.GetJulianComplete();
            GregorianDateTime d    = new GregorianDateTime();

            d.Set(startDate);
            double ayanamsa  = GCAyanamsha.GetAyanamsa(jday);
            double scan_step = 0.5;
            int    prev_naks = 0;
            int    new_naks  = -1;

            double            xj;
            GregorianDateTime xd = new GregorianDateTime();

            longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
            l1            = GCMath.putIn360(longitudeMoon - ayanamsa);
            prev_naks     = GCMath.IntFloor(l1 / phi);

            int counter = 0;

            while (counter < 20)
            {
                xj = jday;
                xd.Set(d);

                jday    += scan_step;
                d.shour += scan_step;
                if (d.shour > 1.0)
                {
                    d.shour -= 1.0;
                    d.NextDay();
                }

                longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
                l2            = GCMath.putIn360(longitudeMoon - ayanamsa);
                new_naks      = GCMath.IntFloor(l2 / phi);
                if (prev_naks != new_naks)
                {
                    jday = xj;
                    d.Set(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }
            nextDate = new GregorianDateTime();
            nextDate.Set(d);
            return(new_naks);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="julianDateUTC">This contains time UTC, that means time observed on Greenwich meridian. DateTime in other
        /// timezones should be converted into timezone UTC+0h before using in this method.</param>
        /// <returns></returns>
        public double GetAscendantDegrees(double julianDateUTC)
        {
            double A         = GCEarthData.SiderealTimeLocal(julianDateUTC, longitudeDeg, OffsetUtcHours * 15.0);
            double E         = 23.4392911;
            double ascendant = GCMath.arcTan2Deg(-GCMath.cosDeg(A), GCMath.sinDeg(A) * GCMath.cosDeg(E) + GCMath.tanDeg(latitudeDeg) * GCMath.sinDeg(E));

            if (ascendant < 180)
            {
                ascendant += 180;
            }
            else
            {
                ascendant -= 180;
            }
            return(GCMath.putIn360(ascendant - GCAyanamsha.GetAyanamsa(julianDateUTC)));
        }
예제 #5
0
        /*********************************************************************/
        /*  Finds next time when rasi is changed                             */
        /*                                                                   */
        /*  startDate - starting date and time, timezone member must be valid */
        /*  zodiac [out] - found zodiac sign into which is changed           */
        /*                                                                   */
        /*********************************************************************/

        public static GregorianDateTime GetNextSankranti(GregorianDateTime startDate, GCEarthData earth, out int zodiac)
        {
            GregorianDateTime d = new GregorianDateTime();
            double            step = 1.0;
            int               count = 0;
            double            ld, prev;
            int               prev_rasi, new_rasi;
            GregorianDateTime prevday;

            d.Set(startDate);
            //d.ChangeTimeZone(0.0);
            //d.shour = 0.0;
            zodiac = 0;

            prev      = GCMath.putIn360(GCCoreAstronomy.GetSunLongitude(d, earth) - GCAyanamsha.GetAyanamsa(d.GetJulian()));
            prev_rasi = GCMath.IntFloor(prev / 30.0);

            while (count < 20)
            {
                prevday = new GregorianDateTime();
                prevday.Set(d);
                d.shour += step;
                if (d.shour > 1.0)
                {
                    d.shour -= 1.0;
                    d.NextDay();
                }

                ld       = GCMath.putIn360(GCCoreAstronomy.GetSunLongitude(d, earth) - GCAyanamsha.GetAyanamsa(d.GetJulian()));
                new_rasi = GCMath.IntFloor(ld / 30.0);

                if (prev_rasi != new_rasi)
                {
                    zodiac = new_rasi;
                    //v uplynulom dni je sankranti
                    step *= 0.5;
                    d.Set(prevday);
                    count++;
                    continue;
                }
            }

            return(d);
        }
예제 #6
0
        /*********************************************************************/
        /*                                                                   */
        /* Calculation of tithi, paksa, naksatra, yoga for given             */
        /*    Gregorian date                                                 */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public int DayCalc(GregorianDateTime date, GCEarthData earth)
        {
            double d;

            // sun position on sunrise on that day
            sunRise = GCSunData.CalcSunrise(date, earth);
            sunSet  = GCSunData.CalcSunset(date, earth);

            // arunodaya is 96 min before sunrise
            //  sunrise_deg is from range 0-360 so 96min=24deg
            sunArunodaya.TotalDays = sunRise.TotalDays - 96 / 1440.0;
            sunArunodaya.longitude = sunRise.longitude - (24.0 / 365.25);
            // noon
            sunNoon.TotalDays = (sunSet.TotalDays + sunRise.TotalDays) / 2;
            sunNoon.longitude = (sunRise.longitude + sunSet.longitude) / 2;

            date.shour = sunRise.TotalDays;

            // date.shour is [0..1] time of sunrise in local timezone time
            this.JulianDay = date.GetJulianDetailed();

            // moon position at sunrise on that day
            sunRise.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);

            this.Ayanamsa         = GCAyanamsha.GetAyanamsa(this.JulianDay);
            sunArunodaya.Ayanamsa = this.Ayanamsa;
            sunRise.Ayanamsa      = this.Ayanamsa;
            sunNoon.Ayanamsa      = this.Ayanamsa;
            sunSet.Ayanamsa       = this.Ayanamsa;

            // masa
            this.Masa = -1;

            date.shour           = sunSet.TotalDays;
            sunSet.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);


            date.shour = sunArunodaya.TotalDays;
            sunArunodaya.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(date, earth);


            return(1);
        }
예제 #7
0
        public double FindNextRasiChange(double startJD, double endJD, int bodyId, out int nNextRasi)
        {
            double jd = startJD;
            double A, B, B1;
            int    C, D;
            double step = 1.0;

            A   = (GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd) - GCAyanamsha.GetAyanamsa(jd)) / 30.0;
            jd += step;
            B1  = A;
            B   = (GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd) - GCAyanamsha.GetAyanamsa(jd)) / 30.0;
            C   = GCMath.IntFloor(A);
            D   = GCMath.IntFloor(B);

            while (jd < endJD && Math.Abs(B1 - B) >= 1 / 86400.0)
            {
                if (C == D)
                {
                    // goto next date
                    A = B;
                    C = D;
                }
                else if (C < D)
                {
                    jd    = jd - step;
                    step *= (D - A) / (B - A);
                }
                else // C > D
                {
                    jd    = jd - step;
                    step *= (C - B) / (A - B);
                }

                jd += step;
                B1  = B;
                B   = (GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd) - GCAyanamsha.GetAyanamsa(jd)) / 30.0;
                D   = GCMath.IntFloor(B);
            }

            nNextRasi = GCMath.IntFloor((GCVSOPAstronomy.GetPlanetLongitude(bodyId, jd + 0.1) - GCAyanamsha.GetAyanamsa(jd)) / 30.0);
            return(jd);
        }
예제 #8
0
        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();
        }
예제 #9
0
        /// <summary>
        /// Main function for CALENDAR calculations
        /// </summary>
        /// <param name="loc"></param>
        /// <param name="begDate"></param>
        /// <param name="iCount"></param>
        /// <returns></returns>
        public int CalculateCalendar(GCLocation loc, GregorianDateTime begDate, int iCount)
        {
            int i, weekday;
            int nTotalCount = BEFORE_DAYS + iCount + BEFORE_DAYS;
            GregorianDateTime date;
            GCEarthData       earth;
            int    lastMasa  = 0;
            int    lastGYear = 0;
            String tempStr;
            bool   bCalcMoon = (GCDisplaySettings.Current.getValue(4) > 0 || GCDisplaySettings.Current.getValue(5) > 0);

            m_nCount   = 0;
            m_Location = loc;
            m_vcStart  = new GregorianDateTime(begDate);
            m_vcCount  = iCount;
            earth      = loc.GetEarthData();

            // alokacia pola
            m_pData = new VAISNAVADAY[nTotalCount];

            // inicializacia poctovych premennych
            m_nCount    = nTotalCount;
            m_PureCount = iCount;

            date = new GregorianDateTime();
            date.Set(begDate);
            date.shour         = 0.0;
            date.TimezoneHours = loc.OffsetUtcHours;
            date.SubtractDays(BEFORE_DAYS);
            date.InitWeekDay();

            weekday = date.dayOfWeek;

            GCFestivalSpecialExecutor exec = new GCFestivalSpecialExecutor(this);

            long utcDayStart = -1;
            long utcDayEnd   = -1;

            // 1
            // initialization of days
            for (i = 0; i < nTotalCount; i++)
            {
                m_pData[i]                = new VAISNAVADAY();
                m_pData[i].date           = new GregorianDateTime(date);
                m_pData[i].date.dayOfWeek = weekday;
                date.NextDay();
                weekday = (weekday + 1) % 7;
                m_pData[i].moonrise.SetValue(-1);
                m_pData[i].moonset.SetValue(-1);

                if (utcDayStart < 0)
                {
                    utcDayStart = Convert.ToInt64(m_pData[i].date.GetJulianComplete() * 86400);
                }
                m_pData[i].UtcDayStart = utcDayStart;
                utcDayStart           += 86400;
            }

            for (i = 0; i < nTotalCount; i++)
            {
                m_pData[i].Previous = i > 0 ? m_pData[i - 1] : null;
                m_pData[i].Next     = i < nTotalCount - 1 ? m_pData[i + 1] : null;
            }

            TResultCoreEvents recentEvents = null;

            // 2
            // calculating DST data and core events
            foreach (VAISNAVADAY t in m_pData)
            {
                t.BiasMinutes = loc.TimeZone.GetBiasMinutesForDay(t.date);
                if (t.Previous != null)
                {
                    t.DstDayType = (t.BiasMinutes == 0
                        ? (t.Previous.BiasMinutes == 0 ? DstTypeChange.DstOff : DstTypeChange.DstEnd)
                        : (t.Previous.BiasMinutes == 0 ? DstTypeChange.DstStart : DstTypeChange.DstOn));
                }

                utcDayStart = t.UtcDayStart - (t.Previous != null ? t.Previous.BiasMinutes * 60 : 0);
                utcDayEnd   = t.UtcDayStart + 86400 - t.BiasMinutes * 60;

                if (recentEvents == null || recentEvents.p_events.Count == 0 || recentEvents.Year != t.date.year)
                {
                    recentEvents = GCCoreAstronomy.GetCoreEventsYear(loc, t.date.year);
                }
                recentEvents.GetCoreEvents(t.coreEvents, utcDayStart, utcDayEnd);


                utcDayStart = utcDayEnd;
            }

            // 3
            if (bCalcMoon)
            {
                foreach (VAISNAVADAY t in m_pData)
                {
                    GCMoonData.CalcMoonTimes(earth, t.date, Convert.ToDouble(t.BiasMinutes / 60.0), out t.moonrise, out t.moonset);

                    if (!EkadasiOnly && GCDisplaySettings.Current.getValue(GCDS.CAL_MOON_RISE) != 0 && t.moonrise.hour >= 0)
                    {
                        tempStr = t.Format(GCStrings.Localized("Moonrise {moonRiseTime} ({dstSig})"));
                        t.AddEvent(DisplayPriorities.PRIO_MOON, GCDS.CAL_MOON_RISE, tempStr);
                    }

                    if (!EkadasiOnly && GCDisplaySettings.Current.getValue(GCDS.CAL_MOON_SET) != 0 && t.moonset.hour >= 0)
                    {
                        tempStr = t.Format(GCStrings.Localized("Moonset {moonSetTime} ({dstSig})"));
                        t.AddEvent(DisplayPriorities.PRIO_MOON, GCDS.CAL_MOON_SET, tempStr);
                    }
                }
            }

            // 4
            // init of astro data
            foreach (VAISNAVADAY t in m_pData)
            {
                t.astrodata = new GCAstroData();
                t.astrodata.DayCalc(t.date, earth);

                t.coreEvents.InsertByTime(new TCoreEvent()
                {
                    Time  = t.UtcDayStart + (long)t.astrodata.sunArunodaya.TotalSeconds,
                    nType = CoreEventType.CCTYPE_S_ARUN
                });
                t.coreEvents.InsertByTime(new TCoreEvent()
                {
                    Time  = t.UtcDayStart + (long)t.astrodata.sunRise.TotalSeconds,
                    nType = CoreEventType.CCTYPE_S_RISE
                });
                t.coreEvents.InsertByTime(new TCoreEvent()
                {
                    Time  = t.UtcDayStart + (long)t.astrodata.sunNoon.TotalSeconds,
                    nType = CoreEventType.CCTYPE_S_NOON
                });
                t.coreEvents.InsertByTime(new TCoreEvent()
                {
                    Time  = t.UtcDayStart + (long)t.astrodata.sunSet.TotalSeconds,
                    nType = CoreEventType.CCTYPE_S_SET
                });
            }

            // 5
            // init of masa
            foreach (VAISNAVADAY t in m_pData)
            {
                if (t.Previous == null ||
                    t.astrodata.sunRise.Paksa != t.Previous.astrodata.sunRise.Paksa)
                {
                    t.astrodata.MasaCalc(t.date, earth);
                    lastMasa  = t.astrodata.Masa;
                    lastGYear = t.astrodata.GaurabdaYear;
                }
                t.astrodata.Masa         = lastMasa;
                t.astrodata.GaurabdaYear = lastGYear;

                if (!EkadasiOnly && GCDisplaySettings.Current.getValue(GCDS.CAL_SUN_LONG) != 0)
                {
                    tempStr = string.Format("{0}: {1} (*)", GCStrings.Localized("Sun Longitude")
                                            , t.astrodata.sunRise.longitude);
                    t.AddEvent(DisplayPriorities.PRIO_ASTRO, GCDS.CAL_SUN_LONG, tempStr);
                }

                if (!EkadasiOnly && GCDisplaySettings.Current.getValue(GCDS.CAL_MOON_LONG) != 0)
                {
                    tempStr = string.Format("{0}: {1} (*)", GCStrings.Localized("Moon Longitude")
                                            , t.astrodata.sunRise.longitudeMoon);
                    t.AddEvent(DisplayPriorities.PRIO_ASTRO, GCDS.CAL_MOON_LONG, tempStr);
                }

                if (!EkadasiOnly && GCDisplaySettings.Current.getValue(GCDS.CAL_AYANAMSHA) != 0)
                {
                    tempStr = string.Format("{0} {1} ({2}) (*)", GCStrings.Localized("Ayanamsha")
                                            , t.astrodata.Ayanamsa
                                            , GCAyanamsha.GetAyanamsaName(GCAyanamsha.GetAyanamsaType()));
                    t.AddEvent(DisplayPriorities.PRIO_ASTRO, GCDS.CAL_AYANAMSHA, tempStr);
                }

                if (!EkadasiOnly && GCDisplaySettings.Current.getValue(GCDS.CAL_JULIAN) != 0)
                {
                    tempStr = string.Format("{0} {1} (*)", GCStrings.Localized("Julian Time")
                                            , t.astrodata.JulianDay);
                    t.AddEvent(DisplayPriorities.PRIO_ASTRO, GCDS.CAL_JULIAN, tempStr);
                }
            }


            if (!EkadasiOnly && GCDisplaySettings.Current.getValue(GCDS.CAL_MASA_CHANGE) != 0)
            {
                String str;

                foreach (VAISNAVADAY t in m_pData)
                {
                    if (t.Previous != null && t.Previous.astrodata.Masa != t.astrodata.Masa)
                    {
                        str = t.Format(GCStrings.Localized("First day of {masaName} Masa"));
                        t.AddEvent(DisplayPriorities.PRIO_MASA_CHANGE, GCDS.CAL_MASA_CHANGE, str);
                    }

                    if (t.Next != null && t.Next.astrodata.Masa != t.astrodata.Masa)
                    {
                        str = t.Format(GCStrings.Localized("Last day of {masaName} Masa"));
                        t.AddEvent(DisplayPriorities.PRIO_MASA_CHANGE, GCDS.CAL_MASA_CHANGE, str);
                    }
                }
            }

            if (!EkadasiOnly && GCDisplaySettings.Current.getValue(GCDS.CAL_DST_CHANGE) != 0)
            {
                foreach (VAISNAVADAY t in m_pData)
                {
                    if (t.Previous != null && t.Previous.BiasMinutes == 0 && t.BiasMinutes != 0)
                    {
                        t.AddEvent(DisplayPriorities.PRIO_DST_CHANGE, GCDS.CAL_DST_CHANGE, GCStrings.Localized("First day of Daylight Saving Time"));
                    }
                    else if (t.Next != null && t.BiasMinutes != 0 && t.Next.BiasMinutes == 0)
                    {
                        t.AddEvent(DisplayPriorities.PRIO_DST_CHANGE, GCDS.CAL_DST_CHANGE, GCStrings.Localized("Last day of Daylight Saving Time"));
                    }
                }
            }

            // 6
            // init of mahadvadasis
            foreach (VAISNAVADAY t in m_pData)
            {
                t.MahadvadasiCalc(earth);
            }

            //
            // init for Ekadasis
            foreach (VAISNAVADAY t in m_pData)
            {
                if (t.Previous == null)
                {
                    continue;
                }
                t.EkadasiCalc(earth);
                if (t.Previous.nFastID == FastType.FAST_EKADASI)
                {
                    t.CalculateEParana(earth);
                }
            }

            if (EkadasiOnly)
            {
                return(1);
            }

            // init ksaya data
            // init of second day of vriddhi
            CalculateKsayaVriddhiTithis();

            //
            // calculate sankrantis
            CalculateSankrantis();

            // 7
            // init of festivals
            AddMatchedFestivals(exec);

            //
            // apply daylight saving time
            ApplyDaylightSavingHours();

            //
            // resolve festivals fasting
            for (i = BEFORE_DAYS; i < m_PureCount + BEFORE_DAYS; i++)
            {
                ResolveFestivalsFasting(i);

                if (GCDisplaySettings.Current.getValue(GCDS.CAL_SUN_RISE) != 0)
                {
                    tempStr = string.Format("{0}-{1}-{2}  {3} - {4} - {5} ({6})",
                                            GCStrings.Localized("Sunrise"),
                                            GCStrings.Localized("Noon"),
                                            GCStrings.Localized("Sunset"),
                                            m_pData[i].astrodata.sunRise.ToShortTimeString(),
                                            m_pData[i].astrodata.sunNoon.ToShortTimeString(),
                                            m_pData[i].astrodata.sunSet.ToShortTimeString(),
                                            GCStrings.GetDSTSignature(m_pData[i].BiasMinutes));
                    m_pData[i].AddEvent(DisplayPriorities.PRIO_SUN, GCDS.CAL_SUN_RISE, tempStr);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.CAL_SUN_SANDHYA) != 0)
                {
                    tempStr = string.Format("{0}: {1} | {2} | {3}   ({4})",
                                            GCStrings.Localized("Sandhyas"),
                                            m_pData[i].astrodata.sunRise.ShortSandhyaString(),
                                            m_pData[i].astrodata.sunNoon.ShortSandhyaString(),
                                            m_pData[i].astrodata.sunSet.ShortSandhyaString(),
                                            GCStrings.GetDSTSignature(m_pData[i].BiasMinutes));
                    m_pData[i].AddEvent(DisplayPriorities.PRIO_SUN, GCDS.CAL_SUN_SANDHYA, tempStr);
                }

                if (GCDisplaySettings.Current.getValue(GCDS.CAL_BRAHMA_MUHURTA) != 0)
                {
                    tempStr = string.Format("{0}: {1}   ({2})",
                                            GCStrings.Localized("Brahma Muhurta"),
                                            m_pData[i].astrodata.sunRise.ShortMuhurtaString(-2),
                                            GCStrings.GetDSTSignature(m_pData[i].BiasMinutes));
                    m_pData[i].AddEvent(DisplayPriorities.PRIO_SUN, GCDS.CAL_BRAHMA_MUHURTA, tempStr);
                }
            }

            if (GCDisplaySettings.Current.getValue(GCDS.CAL_COREEVENTS) != 0)
            {
                int number = 1;
                foreach (VAISNAVADAY today in m_pData)
                {
                    foreach (TCoreEvent tde in today.coreEvents)
                    {
                        m_pData[i].AddEvent(DisplayPriorities.PRIO_ASTRO + number, GCDS.CAL_COREEVENTS,
                                            tde.TypeString + "   " + today.GetCoreEventTime(tde));
                        number++;
                    }
                }
            }


            // sorting day events according priority
            VAISNAVAEVENTComparer vec = new VAISNAVAEVENTComparer();

            foreach (VAISNAVADAY t in m_pData)
            {
                t.dayEvents.Sort(vec);
            }


            return(1);
        }
예제 #10
0
        private void CalculatePlanetRasi(int bodyId, GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCConfigRatedEvents rec)
        {
            int    nData;
            double JD, JDE;

            JD    = vcAdd.GetJulian() - 0.5 - loc.OffsetUtcHours / 24.0;
            JDE   = vcEnd.GetJulian() + 0.5 - loc.OffsetUtcHours / 24.0;
            nData = GCMath.IntFloor(GCMath.putIn360(GCVSOPAstronomy.GetPlanetLongitude(bodyId, JD) - GCAyanamsha.GetAyanamsa(JD)) / 30.0);

            // initial rasi at the start date 00:00
            AddRating(JD, loc, rec.rateGrahaRasi[bodyId, nData], rec.rateGrahaRasi[bodyId, Prev(nData, 12)]);

            while ((JD = FindNextRasiChange(JD, JDE, bodyId, out nData)) < JDE)
            {
                AddRating(JD, loc, rec.rateGrahaRasi[bodyId, nData], rec.rateGrahaRasi[bodyId, Prev(nData, 12)]);
                JD += 1.0;
            }
        }
예제 #11
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);
            }
        }
예제 #12
0
        public void calculateAppDay(GCLocation location, GregorianDateTime eventDate)
        {
            //MOONDATA moon;
            //SUNDATA sun;
            GCAstroData       d       = this.details = new GCAstroData();
            GregorianDateTime vc      = new GregorianDateTime();
            GregorianDateTime vcsun   = new GregorianDateTime();
            GCEarthData       m_earth = location.GetEarthData();

            vc.Set(eventDate);
            vcsun.Set(eventDate);

            this.b_adhika  = false;
            this.eventTime = new GregorianDateTime(eventDate);
            Location       = location;

            //d.nTithi = GetPrevTithiStart(m_earth, vc, dprev);
            //GetNextTithiStart(m_earth, vc, dnext);
            vcsun.shour -= vcsun.TimezoneHours / 24.0;
            vcsun.NormalizeValues();
            vcsun.TimezoneHours     = 0.0;
            d.sunRise               = new GCHourTime();
            d.sunRise.TotalDays     = vc.shour;
            d.sunRise.longitude     = GCCoreAstronomy.GetSunLongitude(vcsun, m_earth);
            d.sunRise.longitudeMoon = GCCoreAstronomy.GetMoonLongitude(vcsun, m_earth);
            d.Ayanamsa              = GCAyanamsha.GetAyanamsa(vc.GetJulianComplete());
            d.sunRise.Ayanamsa      = d.Ayanamsa;

            // tithi


            d.Masa = d.MasaCalc(vc, m_earth);
            if (d.Masa == (int)MasaId.ADHIKA_MASA)
            {
                d.Masa        = d.sunRise.RasiOfSun;
                this.b_adhika = true;
            }

            vc.Today();
            vc.TimezoneHours = m_earth.OffsetUtcHours;
            int               m  = 0;
            GaurabdaDate      va = new GaurabdaDate();
            GregorianDateTime vctemp;

            va.tithi = d.sunRise.Tithi;
            va.masa  = d.Masa;
            va.gyear = GCCalendar.GetGaurabdaYear(vc, m_earth);
            if (va.gyear < d.GaurabdaYear)
            {
                va.gyear = d.GaurabdaYear;
            }

            MainInfo.Add(new AppDayInfo(GCStrings.getString(7), eventDate.ToString()));
            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDayInfo(GCStrings.getString(8), eventDate.ShortTimeString()));
            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDayInfo(GCStrings.getString(9), location.Title));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(10), location.GetLatitudeString()));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(11), location.GetLongitudeString()));
            MainInfo.Add(new AppDayInfo(GCStrings.Localized("Timezone"), location.TimeZoneName));
            MainInfo.Add(new AppDayInfo("DST", "N/A"));
            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDayInfo(GCStrings.getString(13), GCTithi.GetName(d.sunRise.Tithi)));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(14), string.Format("{0:00.000}%", d.sunRise.TithiElapse)));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(15), GCNaksatra.GetName(d.sunRise.Naksatra)));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(16), string.Format("{0:00.000}% ({1} pada)", d.sunRise.NaksatraElapse, GCStrings.getString(811 + d.sunRise.NaksatraPada))));
            MainInfo.Add(new AppDayInfo(GCStrings.Localized("Moon Rasi"), GCRasi.GetName(d.sunRise.RasiOfMoon)));
            MainInfo.Add(new AppDayInfo(GCStrings.Localized("Sun Rasi"), GCRasi.GetName(d.sunRise.RasiOfSun)));
            MainInfo.Add(new AppDayInfo(GCStrings.getString(20), GCPaksa.GetName(d.sunRise.Paksa)));

            if (b_adhika == true)
            {
                MainInfo.Add(new AppDayInfo(GCStrings.getString(22), string.Format("{0} {1}", GCMasa.GetName(d.Masa), GCStrings.getString(21))));
            }
            else
            {
                MainInfo.Add(new AppDayInfo(GCStrings.getString(22), GCMasa.GetName(d.Masa)));
            }
            MainInfo.Add(new AppDayInfo(GCStrings.getString(23), d.GaurabdaYear.ToString()));

            if (GCDisplaySettings.Current.getValue(48) == 1)
            {
                MainInfo.Add(new AppDayBase(GCDS.APP_CHILDNAMES));
                MainInfo.Add(new AppDaySeparator(GCStrings.getString(17)));
                MainInfo.Add(new AppDayBase(GCDS.APP_CHILDNAMES));

                MainInfo.Add(new AppDayInfo(GCDS.APP_CHILDNAMES, GCStrings.getString(18), GCStrings.GetNaksatraChildSylable(d.sunRise.Naksatra, d.sunRise.NaksatraPada) + "..."));
                MainInfo.Add(new AppDayInfo(GCDS.APP_CHILDNAMES, GCStrings.getString(19), GCStrings.GetRasiChildSylable(d.sunRise.RasiOfMoon) + "..."));
            }

            MainInfo.Add(new AppDayBase());
            MainInfo.Add(new AppDaySeparator(GCStrings.getString(24)));
            MainInfo.Add(new AppDayBase());


            celeb_date = new GregorianDateTime[TRESULT_APP_CELEBS];
            celeb_gy   = new int[TRESULT_APP_CELEBS];

            for (int i = 0; i < TRESULT_APP_CELEBS + 3; i++)
            {
                GCCalendar.VATIMEtoVCTIME(va, out vctemp, m_earth);
                if (va.gyear > d.GaurabdaYear)
                {
                    if (m < TRESULT_APP_CELEBS)
                    {
                        MainInfo.Add(new AppDayInfo(string.Format("Gaurabda {0}", va.gyear), vctemp.ToString()));
                        this.celeb_date[m] = new GregorianDateTime(vctemp);
                        this.celeb_gy[m]   = va.gyear;
                        m++;
                    }
                }
                va.gyear++;
            }
        }
예제 #13
0
        /*********************************************************************/
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*                                                                   */
        /*********************************************************************/

        public int MasaCalc(GregorianDateTime date, GCEarthData earth)
        {
            //	SUNDATA sun;
            //	MOONDATA moon;
            //	VCTIME Conj[6], ConjA;
            //	double Long[6], LongA;
            //	int Sank[6], SankA;

            const int PREV_MONTHS = 6;

            double[]            L = new double[8];
            GregorianDateTime[] C = new GregorianDateTime[8];
            int[] R = new int[8];
            int   n, rasi, masa = MasaId.VISNU_MASA;
            int   ksaya_from = -1;
            int   ksaya_to   = -1;

            date.shour = sunRise.TotalDays;

            // STEP 1: calculate position of the sun and moon
            // it is done by previous call of DayCalc
            // and results are in argument DAYDATA day
            // *DayCalc(date, earth, day, moon, sun);*

            L[1] = /*Long[0] =*/ GCConjunction.GetNextConjunction(date, out C[1], false, earth);
            L[0] = /*LongA   =*/ GCConjunction.GetNextConjunction(C[1], out C[0], true, earth);

            // on Pratipat (nTithi == 15) we need to look for previous conjunction
            // but this conjunction can occur on this date before sunrise
            // so we need to include this very date into looking for conjunction
            // on other days we cannot include it
            // and exclude it from looking for next because otherwise that will cause
            // incorrect detection of Purusottama adhika masa
            L[2] = GCConjunction.GetPrevConjunction(date, out C[2], false, earth);

            for (n = 3; n < PREV_MONTHS; n++)
            {
                L[n] = GCConjunction.GetPrevConjunction(C[n - 1], out C[n], true, earth);
            }

            for (n = 0; n < PREV_MONTHS; n++)
            {
                R[n] = GCRasi.GetRasi(L[n], GCAyanamsha.GetAyanamsa(C[n].GetJulian()));
            }

            /*	TRACE("TEST Date: %d %d %d ", date.day, date.month, date.year);
             *  TRACE("FOUND CONJ Date: %d %d %d rasi: %d ", C[1].day, C[1].month, C[1].year, R[1]);
             *  TRACE("FOUND CONJ Date: %d %d %d rasi: %d ", C[2].day, C[2].month, C[2].year, R[2]);
             *  TRACE("FOUND CONJ Date: %d %d %d rasi: %d ", C[3].day, C[3].month, C[3].year, R[3]);
             *  TRACE("FOUND CONJ Date: %d %d %d rasi: %d ", C[4].day, C[4].month, C[4].year, R[4]);
             *  TRACE("---
             */
            // test for Adhika-Ksaya sequence
            // this is like 1-2-2-4-5...
            // second (2) is replaced by rasi(3)

            /*	if ( ((Sank[1] + 2) % 12 == SankA) && ((Sank[1] == Sank[0]) || (Sank[0] == SankA)))
             *  {
             *      Sank[0] = (Sank[1] + 1) % 12;
             *  }
             *
             *  if ( ((Sank[2] + 2) % 12 == Sank[0]) && ((Sank[2] == Sank[1]) || (Sank[1] == Sank[0])))
             *  {
             *      Sank[1] = (Sank[2] + 1) % 12;
             *  }*/

            // look for ksaya month
            ksaya_from = -1;
            for (n = PREV_MONTHS - 2; n >= 0; n--)
            {
                if ((R[n + 1] + 2) % 12 == R[n])
                {
                    ksaya_from = n;
                    break;
                }
            }

            if (ksaya_from >= 0)
            {
                for (n = ksaya_from; n > 0; n--)
                {
                    if (R[n] == R[n - 1])
                    {
                        ksaya_to = n;
                        break;
                    }
                }

                if (ksaya_to >= 0)
                {
                    // adhika masa found
                    // now correct succession of rasis
                }
                else
                {
                    // adhika masa not found
                    // there will be some break in masa queue
                    ksaya_to = 0;
                }

                int current_rasi = R[ksaya_from + 1] + 1;
                for (n = ksaya_from; n >= ksaya_to; n--)
                {
                    R[n]         = current_rasi;
                    current_rasi = (current_rasi + 1) % 12;
                }
            }

            // STEP 3: test for adhika masa
            // test for adhika masa
            if (R[1] == R[2])
            {
                // it is adhika masa
                masa = 12;
                rasi = R[1];
            }
            else
            {
                // STEP 2. select nearest Conjunction
                if (this.sunRise.Paksa == 0)
                {
                    masa = R[1];
                }
                else if (this.sunRise.Paksa == 1)
                {
                    masa = R[2];
                }
                rasi = masa;
            }

            // calculation of Gaurabda year
            GaurabdaYear = date.year - 1486;

            if ((rasi > 7) && (rasi < 11)) // Visnu
            {
                if (date.month < 6)
                {
                    GaurabdaYear--;
                }
            }

            Masa = masa;

            return(masa);
        }