예제 #1
0
 public string GetCoreEventTime(TCoreEvent tce)
 {
     return(GregorianDateTime.TimeSpanToLongString(tce.GetDstTime(this.BiasMinutes * 60) - this.UtcDayStart)
            + " ("
            + GCStrings.GetDSTSignature(tce.nDst * this.BiasMinutes)
            + ")");
 }
예제 #2
0
        public GregorianDateTime GetGregorianDateTime(TCoreEvent ce)
        {
            GregorianDateTime gdt = new GregorianDateTime(date);

            gdt.shour = (ce.GetDstTime(BiasMinutes * 60) - UtcDayStart) / 86400.0;
            return(gdt);
        }
예제 #3
0
        // return values
        // 0 - DST is off, yesterday was off
        // 1 - DST is on, yesterday was off
        // 2 - DST is on, yesterday was on
        // 3 - DST is off, yesterday was on
        public DstTypeChange DetermineDaylightChange(GregorianDateTime vc2)
        {
            int t2 = this.GetBiasMinutesForDay(vc2);
            GregorianDateTime vc3 = new GregorianDateTime();

            vc3.Set(vc2);
            vc3.PreviousDay();
            int t1 = this.GetBiasMinutesForDay(vc3);

            if (t1 != 0)
            {
                if (t2 != 0)
                {
                    return(DstTypeChange.DstOn);
                }
                else
                {
                    return(DstTypeChange.DstEnd);
                }
            }
            else if (t2 != 0)
            {
                return(DstTypeChange.DstStart);
            }
            else
            {
                return(DstTypeChange.DstOff);
            }
        }
예제 #4
0
        private int CalculateYoga(GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCEarthData earth, GCConfigRatedEvents rec)
        {
            int nData = 0;
            GregorianDateTime vcNext = new GregorianDateTime();
            int ndst;

            vcAdd.SubtractDays(1);
            while (vcAdd.IsBeforeThis(vcEnd))
            {
                nData = GCYoga.GetNextYogaStart(earth, vcAdd, out vcNext);
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                {
                    vcNext.InitWeekDay();
                    vcNext.AddHours(loc.TimeZone.GetBiasMinutesForDay(vcNext) / 60.0);
                    //AddEvent(vcNext, CoreEventType.CCTYPE_YOGA, nData, ndst);
                    AddRating(vcNext, rec.rateYoga[nData], rec.rateYoga[Prev(nData, 27)]);
                }
                else
                {
                    break;
                }
                vcAdd.Set(vcNext);
                vcAdd.shour += 0.2;
                if (vcAdd.shour >= 1.0)
                {
                    vcAdd.shour -= 1.0;
                    vcAdd.NextDay();
                }
            }
            return(nData);
        }
예제 #5
0
        /// <summary>
        /// Tests whether this date is equal or after the date, when given weekday in given week occurs.
        /// </summary>
        /// <param name="weekNumber">Number of week. values 1, 2, 3, 4 are order of week, value 5 means last week of the month</param>
        /// <param name="dayNumber">Number of weekday, value 0 is Sunday, 1 is Monday, .... 6 is Saturday</param>
        /// <returns>Returns true, if this date is equal or is after the date given by weeknumber and daynumber</returns>
        public bool IsEqualOrAfterWeekdayInWeek(int weekNumber, int dayNumber)
        {
            GregorianDateTime vc = this;

            int[] xx = { 1, 7, 6, 5, 4, 3, 2 };

            int dowFirstDay, firstGivenWeekday, requiredGivenWeekday, lastDayInMonth;

            // prvy den mesiaca
            dowFirstDay = xx[(7 + vc.day - vc.dayOfWeek) % 7];

            // 1. x-day v mesiaci ma datum
            firstGivenWeekday = xx[(dowFirstDay - dayNumber + 7) % 7];

            // n-ty x-day ma datum
            if ((weekNumber < 0) || (weekNumber >= 5))
            {
                requiredGivenWeekday = firstGivenWeekday + 28;
                lastDayInMonth       = GregorianDateTime.GetMonthMaxDays(vc.year, vc.month);
                while (requiredGivenWeekday > lastDayInMonth)
                {
                    requiredGivenWeekday -= 7;
                }
            }
            else
            {
                requiredGivenWeekday = Convert.ToInt32(firstGivenWeekday + (weekNumber - 1) * 7);
            }

            return(vc.day >= requiredGivenWeekday);
        }
예제 #6
0
 public void NormalizeValues(ref int y1, ref int m1, ref int d1, ref double h1)
 {
     if (h1 < 0.0)
     {
         d1--;
         h1 += 1.0;
     }
     else if (h1 >= 1.0)
     {
         h1 -= 1.0;
         d1++;
     }
     if (d1 < 1)
     {
         m1--;
         if (m1 < 1)
         {
             m1 = 12;
             y1--;
         }
         d1 = GregorianDateTime.GetMonthMaxDays(y1, m1);
     }
     else if (d1 > GregorianDateTime.GetMonthMaxDays(y1, m1))
     {
         m1++;
         if (m1 > 12)
         {
             m1 = 1;
             y1++;
         }
         d1 = 1;
     }
 }
예제 #7
0
        private void CalculateSunRasi(GCLocation loc, GregorianDateTime vcEnd, GregorianDateTime vcAdd, GCConfigRatedEvents rec)
        {
            int nData;
            GregorianDateTime vcNext = new GregorianDateTime();
            int         ndst;
            GCEarthData earth = loc.GetEarthData();

            vcAdd.SubtractDays(30);

            while (vcAdd.IsBeforeThis(vcEnd))
            {
                vcNext.Set(GCSankranti.GetNextSankranti(vcAdd, earth, out nData));
                if (vcNext.GetDayInteger() < vcEnd.GetDayInteger())
                {
                    vcNext.InitWeekDay();
                    vcNext.AddHours(loc.TimeZone.GetBiasMinutesForDay(vcNext) / 60.0);
                    //AddEvent(vcNext, CoreEventType.CCTYPE_SANK, nData, ndst);
                    AddRating(vcNext, rec.rateGrahaRasi[0, nData], rec.rateGrahaRasi[0, Prev(nData, 12)]);
                }
                else
                {
                    break;
                }
                vcAdd.Set(vcNext);
                vcAdd.NextDay();
            }
        }
예제 #8
0
        public static int writeFirstDayXml(string fileName, GCLocation loc, GregorianDateTime vcStart)
        {
            using (StreamWriter xml = new StreamWriter(fileName))
            {
                vcStart.Set(GCAstroData.GetFirstDayOfYear(loc.GetEarthData(), vcStart.year));
                vcStart.InitWeekDay();

                // write
                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"FirstDay\" version=\"");
                xml.Write(GCStrings.RawVersionNumber);
                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=\"year\" val=\"");
                xml.Write(vcStart.year);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"FirstDay_of_GaurabdaYear\">\n");
                xml.Write("\t\t<firstday date=\"");
                xml.Write(vcStart);
                xml.Write("\" dayweekid = \"");
                xml.Write(vcStart.dayOfWeek);
                xml.Write("\" dayweek=\"");
                xml.Write(GCCalendar.GetWeekdayName(vcStart.dayOfWeek));
                xml.Write("\" />\n");
                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }
            return(0);
        }
예제 #9
0
        /*************************************/
        /*    sun functions                  */
        /*                                   */
        /*    sun longitude                  */
        /*    sunrise, sunset time           */
        /*                                   */
        /*************************************/

        //////////////////////////////////////////////////////////////////////////
        //
        // VCTIME vct [in] - valid must be each member of this structure
        //

        // from vct uses members: year, month, day
        // double is in range 0.0 - 1.0

        private void SunPosition(GregorianDateTime vct, GCEarthData ed, double dayHours)
        {
            double DG  = GCMath.PI / 180;
            double RAD = 180 / GCMath.PI;

            double dLatitude  = ed.latitudeDeg;
            double dLongitude = ed.longitudeDeg;

            // mean ecliptic longitude of the sun
            meanLongitudeOfSun = GCSunData.SunGetMeanLong(vct.year, vct.month, vct.day) + (360 / 365.25) * dayHours / 360.0;

            // ecliptic longitude of perigee
            double elp = GCSunData.SunGetPerigee(vct.year, vct.month, vct.day);

            // mean anomaly of the sun
            double mas = meanLongitudeOfSun - elp;

            // ecliptic longitude of the sun
            double els = 0.0;

            this.longitudeDeg = els = meanLongitudeOfSun + 1.915 * Math.Sin(mas * DG) + 0.02 * Math.Sin(2 * DG * mas);

            // declination of the sun
            this.declinationDeg = RAD * Math.Asin(0.39777 * Math.Sin(els * DG));

            // right ascension of the sun
            this.rightAscensionDeg = els - RAD * Math.Atan2(Math.Sin(2 * els * DG), 23.2377 + Math.Cos(2 * DG * els));

            // equation of time
            equationOfTime = this.rightAscensionDeg - meanLongitudeOfSun;
        }
예제 #10
0
        /*********************************************************************/
        /*  Finds date of Pratipat, Krsna Paksa, Visnu Masa                  */
        /*                                                                   */
        /*  EARTHDATA earth - location                                       */
        /*  int nYear       - Gregorian year                                 */
        /*                                                                   */
        /*********************************************************************/

        public static GregorianDateTime GetFirstDayOfYear(GCEarthData earth, int nYear)
        {
            int[]             a = { 2, 15, 3, 1, 3, 15, 4, 1, 4, 15 };
            GregorianDateTime d = new GregorianDateTime();
            GCAstroData       day = new GCAstroData();
            int    gy, j, masa;
            int    step;
            UInt32 tmp;

            if (nYear >= 1950 && nYear < 2058)
            {
                tmp     = gGaurBeg[(nYear - 1950) * 26 + 22];
                d.month = (int)(tmp & 0x3e0) >> 5;
                d.day   = (int)(tmp & 0x1f);
                d.year  = nYear;
                d.NextDay();
                a[0] = d.month;
                a[1] = d.day;
            }

            for (int i = 0; i < 10; i += 2)
            {
                d.year  = nYear;
                d.month = a[i];
                d.day   = a[i + 1];

                day.DayCalc(d, earth);
                masa = day.MasaCalc(d, earth);
                gy   = day.GaurabdaYear;

                if (masa == 11) // visnu masa
                {
                    do
                    {
                        // shifts date
                        step = day.sunRise.Tithi / 2;
                        step = (step > 0) ? step : 1;
                        for (j = step; j > 0; j--)
                        {
                            d.PreviousDay();
                        }
                        // try new time
                        day.DayCalc(d, earth);
                    }while (day.sunRise.Tithi < 28);
                    d.NextDay();
                    d.TimezoneHours = earth.OffsetUtcHours;
                    d.shour         = day.sunRise.TotalDays;
                    return(d);
                }
            }

            d.year          = -1;
            d.month         = -1;
            d.day           = -1;
            d.TimezoneHours = earth.OffsetUtcHours;
            d.shour         = day.sunRise.TotalDays;

            return(d);
        }
예제 #11
0
 public int GetNormalTimeStartDate(int nYear, ref GregorianDateTime vcStart)
 {
     vcStart.day   = 1;
     vcStart.month = 10;
     vcStart.year  = nYear;
     vcStart.shour = 3 / 24.0;
     return(0);
 }
예제 #12
0
        public GregorianDateTime TimeWithOffset(double p)
        {
            GregorianDateTime dt = new GregorianDateTime(this);

            dt.shour += p;
            dt.NormalizeValues();
            return(dt);
        }
예제 #13
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);
        }
예제 #14
0
 public void Set(GregorianDateTime ta)
 {
     year          = ta.year;
     month         = ta.month;
     day           = ta.day;
     shour         = ta.shour;
     TimezoneHours = ta.TimezoneHours;
     dayOfWeek     = ta.dayOfWeek;
 }
예제 #15
0
 public bool GetNextAscendantBefore(GregorianDateTime stopDateTime)
 {
     if (stopDateTime.GetJulianComplete() < CurrentDateTime.GetJulianComplete())
     {
         return(false);
     }
     GetNextAscendent();
     return(stopDateTime.GetJulianComplete() > CurrentDateTime.GetJulianComplete());
 }
예제 #16
0
        /*********************************************************************/
        /*                                                                   */
        /*   finds previous time when starts next tithi                      */
        /*                                                                   */
        /*   timezone is not changed                                         */
        /*                                                                   */
        /*   return value: index of tithi 0..29                              */
        /*                 or -1 if failed                                   */
        /*********************************************************************/

        public static int GetPrevTithiStart(GCEarthData ed, GregorianDateTime startDate, out GregorianDateTime nextDate)
        {
            double            phi = 12.0;
            double            l1, l2, longitudeSun, longitudeMoon;
            double            jday = startDate.GetJulianComplete();
            double            xj;
            GregorianDateTime d = new GregorianDateTime();

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

            longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
            longitudeSun  = GCCoreAstronomy.GetSunLongitude(d, ed);
            l1            = GCMath.putIn360(longitudeMoon - longitudeSun - 180.0);
            prev_tit      = 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 < 0.0)
                {
                    d.shour += 1.0;
                    d.PreviousDay();
                }

                longitudeSun  = GCCoreAstronomy.GetSunLongitude(d, ed);
                longitudeMoon = GCCoreAstronomy.GetMoonLongitude(d, ed);
                l2            = GCMath.putIn360(longitudeMoon - longitudeSun - 180.0);
                new_tit       = GCMath.IntFloor(l2 / phi);

                if (prev_tit != new_tit)
                {
                    jday = xj;
                    d.Set(xd);
                    scan_step *= 0.5;
                    counter++;
                    continue;
                }
                else
                {
                    l1 = l2;
                }
            }
            nextDate = d;
            //	nextDate.shour += startDate.tzone / 24.0;
            //	nextDate.NormalizeValues();
            return(new_tit);
        }
예제 #17
0
        public static int GetGaurabdaYear(GregorianDateTime vc, GCEarthData earth)
        {
            GCAstroData day = new GCAstroData();

            day.DayCalc(vc, earth);
            day.MasaCalc(vc, earth);

            return(day.GaurabdaYear);
        }
예제 #18
0
        public bool AddEvent(GregorianDateTime inTime, int inType, int inData, DstTypeChange inDst)
        {
            TDayEvent de = new TDayEvent();

            de.Time = new GregorianDateTime();
            de.Time.Set(inTime);

            switch (inDst)
            {
            case DstTypeChange.DstOff:
                de.nDst = 0;
                break;

            case DstTypeChange.DstStart:
                if (de.Time.shour >= 2 / 24.0)
                {
                    de.Time.shour += 1 / 24.0;
                    de.Time.NormalizeValues();
                    de.nDst = 1;
                }
                else
                {
                    de.nDst = 0;
                }
                break;

            case DstTypeChange.DstOn:
                de.Time.shour += 1 / 24.0;
                de.Time.NormalizeValues();
                de.nDst = 1;
                break;

            case DstTypeChange.DstEnd:
                if (de.Time.shour <= 2 / 24.0)
                {
                    de.Time.shour += 1 / 24.0;
                    de.Time.NormalizeValues();
                    de.nDst = 1;
                }
                else
                {
                    de.nDst = 0;
                }
                break;

            default:
                de.nDst = 0;
                break;
            }
            de.nData = inData;
            de.nType = inType;

            p_events.Add(de);

            return(true);
        }
예제 #19
0
        public bool AddEvent(GregorianDateTime time, int inType, int inData, int inDst)
        {
            TDayEvent de = new TDayEvent();

            de.Time = new GregorianDateTime(time);

            switch (inDst)
            {
            case 0:
                de.nDst = 0;
                break;

            case 1:
                if (de.Time.shour >= 2 / 24.0)
                {
                    de.Time.shour += 1 / 24.0;
                    de.Time.NormalizeValues();
                    de.nDst = 1;
                }
                else
                {
                    de.nDst = 0;
                }
                break;

            case 2:
                de.Time.shour += 1 / 24.0;
                de.Time.NormalizeValues();
                de.nDst = 1;
                break;

            case 3:
                if (de.Time.shour <= 2 / 24.0)
                {
                    de.Time.shour += 1 / 24.0;
                    de.Time.NormalizeValues();
                    de.nDst = 1;
                }
                else
                {
                    de.nDst = 0;
                }
                break;

            default:
                de.nDst = 0;
                break;
            }

            de.nData = inData;
            de.nType = inType;

            p_events.Add(de);

            return(true);
        }
예제 #20
0
        //===========================================================================
        //
        //===========================================================================

        public static void VCTIMEtoVATIME(GregorianDateTime vc, out GaurabdaDate va, GCEarthData earth)
        {
            GCAstroData day = new GCAstroData();

            day.DayCalc(vc, earth);
            va       = new GaurabdaDate();
            va.masa  = day.MasaCalc(vc, earth);
            va.tithi = day.sunRise.Tithi;
            va.gyear = day.GaurabdaYear;
        }
예제 #21
0
        /*********************************************************************/
        /* Finds starting and ending time for given tithi                    */
        /*                                                                   */
        /* tithi is specified by Gaurabda year, masa, paksa and tithi number */
        /*      nGYear - 0..9999                                             */
        /*       nMasa - 0..12, 0-Madhusudana, 1-Trivikrama, 2-Vamana        */
        /*                      3-Sridhara, 4-Hrsikesa, 5-Padmanabha         */
        /*                      6-Damodara, 7-Kesava, 8-narayana, 9-Madhava  */
        /*                      10-Govinda, 11-Visnu, 12-PurusottamaAdhika   */
        /*       nPaksa -       0-Krsna, 1-Gaura                             */
        /*       nTithi - 0..14                                              */
        /*       earth  - used timezone                                      */
        /*                                                                   */
        /*********************************************************************/

        public static GregorianDateTime CalcTithiEnd(int nGYear, int nMasa, int nPaksa, int nTithi, GCEarthData earth, out GregorianDateTime endTithi)
        {
            GregorianDateTime d = new GregorianDateTime();

            d.Set(GCAstroData.GetFirstDayOfYear(earth, nGYear + 1486));
            d.shour         = 0.5;
            d.TimezoneHours = earth.OffsetUtcHours;

            return(CalcTithiEndEx(d, nGYear, nMasa, nPaksa, nTithi, earth, out endTithi));
        }
예제 #22
0
        public static double GetSunLongitude(GregorianDateTime vct, GCEarthData earth)
        {
            switch (System)
            {
            case AstronomySystem.Meeus:
                return(GCSunData.GetSunLongitude(vct));
            }

            return(0);
        }
예제 #23
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);
        }
예제 #24
0
 public static int GetMonthMaxDays(int year, int month)
 {
     if (GregorianDateTime.IsLeapYear(year))
     {
         return(m_months_ovr[month]);
     }
     else
     {
         return(m_months[month]);
     }
 }
예제 #25
0
        public static double GetMoonElevation(GCEarthData e, GregorianDateTime vc)
        {
            GCMoonData moon = new GCMoonData();
            double     d    = vc.GetJulianComplete();

            moon.Calculate(d);
            moon.CorrectEqatorialWithParallax(d, e.latitudeDeg, e.longitudeDeg, 0);
            moon.calc_horizontal(d, e.longitudeDeg, e.latitudeDeg);

            return(moon.elevation);
        }
예제 #26
0
        public static GCHourTime CalcSunrise(GregorianDateTime vct, GCEarthData earth)
        {
            double    tempSunrise = 180.0;
            GCSunData sun         = new GCSunData();

            for (int i = 0; i < 3; i++)
            {
                sun.SunPosition(vct, earth, tempSunrise - 180.0);

                double x;
                // definition of event
                double eventdef = 0.01454;

                /*	switch(ed.obs)
                 *  {
                 *  case 1:	// civil twilight
                 *      eventdef = 0.10453;
                 *      break;
                 *  case 2:	// nautical twilight
                 *      eventdef = 0.20791;
                 *      break;
                 *  case 3:	// astronomical twilight
                 *      eventdef = 0.30902;
                 *      break;
                 *  default:// center of the sun on the horizont
                 *      eventdef = 0.01454;
                 *      break;
                 *  }*/

                eventdef = (eventdef / GCMath.cosDeg(earth.latitudeDeg)) / GCMath.cosDeg(sun.declinationDeg);

                x = GCMath.tanDeg(earth.latitudeDeg) * GCMath.tanDeg(sun.declinationDeg) + eventdef;

                if ((x >= -1.0) && (x <= 1.0))
                {
                    // time of sunrise
                    tempSunrise = 90.0 - earth.longitudeDeg - GCMath.arcSinDeg(x) + sun.equationOfTime;
                }
                else
                {
                    // initial values for the case
                    // that no rise no set for that day
                    tempSunrise = -360.0;
                    break;
                }
            }

            GCHourTime result = new GCHourTime();

            result.longitude = sun.longitudeDeg;
            result.SetDegTime(tempSunrise + earth.OffsetUtcHours * 15.0);
            return(result);
        }
예제 #27
0
        public static double GetMoonLongitude(GregorianDateTime vct, GCEarthData earth)
        {
            switch (System)
            {
            case AstronomySystem.Meeus:
                GCMoonData moon = new GCMoonData();
                moon.Calculate(vct.GetJulianComplete());
                return(moon.longitude_deg);
            }

            return(0);
        }
예제 #28
0
        public static XmlDocument GetSankrantiListXml(GCLocation loc, GregorianDateTime vcStart, GregorianDateTime vcEnd)
        {
            GregorianDateTime d = new GregorianDateTime();
            int zodiac;

            XmlDocument doc = new XmlDocument();
            XmlElement  e1  = doc.CreateElement("xml");

            doc.AppendChild(e1);
            XmlElement  e2, e3;
            GCEarthData earth = loc.GetEarthData();

            // open file
            d.Set(vcStart);

            e2 = doc.CreateElement("request");
            e1.AppendChild(e2);
            e2.SetAttribute("name", "Sankranti");
            e2.SetAttribute("version", GCStrings.getString(130));

            e2.SetAttribute("longitude", loc.Longitude.ToString());
            e2.SetAttribute("latitude", loc.Latitude.ToString());
            e2.SetAttribute("timezone", loc.OffsetUtcHours.ToString());
            e2.SetAttribute("startdate", vcStart.ToString());
            e2.SetAttribute("enddate", vcEnd.ToString());

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

            while (d.IsBeforeThis(vcEnd))
            {
                d.Set(GCSankranti.GetNextSankranti(d, earth, out zodiac));
                d.InitWeekDay();

                e3 = doc.CreateElement("sank");
                e2.AppendChild(e3);

                e3.SetAttribute("date", d.ToString());
                e3.SetAttribute("dayweekid", d.dayOfWeek.ToString());
                e3.SetAttribute("dayweek", GCCalendar.GetWeekdayName(d.dayOfWeek));
                e3.SetAttribute("time", d.LongTimeString());
                e3.SetAttribute("rasi", zodiac.ToString());
                e3.SetAttribute("rasiName", GCRasi.GetName(zodiac));
                e3.SetAttribute("rasiNameEn", GCRasi.GetNameEn(zodiac));

                d.NextDay();
                d.NextDay();
            }

            return(doc);
        }
예제 #29
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);
        }
예제 #30
0
        public int FindDate(GregorianDateTime vc)
        {
            int i;

            for (i = BEFORE_DAYS; i < m_nCount; i++)
            {
                if ((m_pData[i].date.day == vc.day) && (m_pData[i].date.month == vc.month) && (m_pData[i].date.year == vc.year))
                {
                    return(i - BEFORE_DAYS);
                }
            }

            return(-1);
        }