Exemple #1
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);
        }
Exemple #2
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));
        }
        /// <summary>
        /// Calculation of Masa List
        /// </summary>
        /// <param name="loc">Location</param>
        /// <param name="nYear">Starting year</param>
        /// <param name="nCount">Number of years</param>
        /// <returns></returns>
        public int CalculateMasaList(GCLocation loc, int nYear, int nCount)
        {
            GCAstroData       day = new GCAstroData();
            GregorianDateTime d = new GregorianDateTime(), de = new GregorianDateTime(), t = new GregorianDateTime();
            int             lm    = -1;
            TResultMasaList mlist = this;
            GCEarthData     earth = loc.GetEarthData();

            mlist.n_startYear  = nYear;
            mlist.n_countYears = nCount;
            mlist.vc_start     = new GregorianDateTime();
            mlist.vc_end       = new GregorianDateTime();
            mlist.vc_start.Set(GCAstroData.GetFirstDayOfYear(earth, nYear));
            mlist.vc_end.Set(GCAstroData.GetFirstDayOfYear(earth, nYear + nCount));
            mlist.m_location = loc;

            d.Set(mlist.vc_start);
            de.Set(mlist.vc_end);

            int i          = 0;
            int prev_paksa = -1;
            int current    = 0;


            while (d.IsBeforeThis(de))
            {
                day.DayCalc(d, earth);
                if (prev_paksa != day.sunRise.Paksa)
                {
                    day.Masa = day.MasaCalc(d, earth);

                    if (lm != day.Masa)
                    {
                        if (lm >= 0)
                        {
                            t.Set(d);
                            t.PreviousDay();
                            if (mlist.arr.Count <= current)
                            {
                                mlist.arr.Add(new TResultMasa());
                            }
                            mlist.arr[current].vc_end = new GregorianDateTime(t);
                            current++;
                        }
                        lm = day.Masa;
                        if (mlist.arr.Count <= current)
                        {
                            mlist.arr.Add(new TResultMasa());
                        }
                        mlist.arr[current].masa     = day.Masa;
                        mlist.arr[current].year     = day.GaurabdaYear;
                        mlist.arr[current].vc_start = new GregorianDateTime(d);
                    }
                }
                prev_paksa = day.sunRise.Paksa;
                d.NextDay();
                i++;
            }

            mlist.arr[current].vc_end = new GregorianDateTime(d);
            current++;
            mlist.n_countMasa = current;

            return(1);
        }