示例#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);
        }
示例#2
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);
        }
示例#3
0
        public override GSCore ExecuteMessage(string token, GSCoreCollection args)
        {
            GSCore result = GSCore.Void;

            switch (token)
            {
            case "canDisplay":
                int  disp = (int)args.getSafe(0).getIntegerValue();
                bool b    = (disp != 0 && (disp == -1 || GCDisplaySettings.Current.getValue(disp) != 0));
                result = new GSBoolean(b);
                break;

            case "getDispValue":
                result = new GSNumber(GCDisplaySettings.Current.getValue((int)args.getSafe(0).getIntegerValue()));
                break;

            case "new":
                switch (args.getSafe(0).getStringValue())
                {
                case "GregorianDateTime":
                    result = new GregorianDateTime();
                    break;

                case "DateTime":
                    result = new GSDateTime();
                    break;

                default:
                    result = GSCore.Void;
                    break;
                }
                break;

            case "calendarHeaderType":
                result = new GSNumber(GCDisplaySettings.Current.CalHeaderType);
                break;

            case "centerText":
                string text    = args.getSafe(0).getStringValue();
                int    length  = (int)args.getSafe(1).getIntegerValue();
                string padStr  = args.getSafe(2).getStringValue();
                char   padChar = padStr.Length > 0 ? padStr[0] : ' ';
                int    half    = (length - text.Length) / 2;
                if (half > 0)
                {
                    result = new GSString(string.Format("{0} {1} {0}", "".PadLeft(half - 1, padChar), text));
                }
                else
                {
                    result = new GSString(text);
                }
                break;

            case "getTabPos":
                double d = args.getSafe(0).getDoubleValue();
                result = new GSNumber(d * GCLayoutData.textSizeText / 24.0);
                break;

            case "getWeekdayName":
                result = new GSString(GCCalendar.GetWeekdayName((int)args.getSafe(0).getIntegerValue()));
                break;

            case "getTimezoneOffset":
            {
                string    tzname   = args.getSafe(0).getStringValue();
                TTimeZone tzid     = TTimeZone.FindTimeZoneByName(tzname);
                int       tzoffset = tzid.OffsetMinutes;
                char      sign     = (tzoffset > 0) ? '+' : '-';
                tzoffset = Math.Abs(tzoffset);
                result   = new GSString(string.Format("{0}{1:00}{2:00}", sign, tzoffset / 60, Math.Abs(tzoffset) % 60));
            }
            break;

            case "getTimezoneOffsetBias":
            {
                string    tzname   = args.getSafe(0).getStringValue();
                TTimeZone tzid     = TTimeZone.FindTimeZoneByName(tzname);
                int       tzoffset = tzid.OffsetMinutes + tzid.BiasMinutes;
                char      sign     = (tzoffset > 0) ? '+' : '-';
                tzoffset = Math.Abs(tzoffset);
                result   = new GSString(string.Format("{0}{1:00}{2:00}", sign, tzoffset / 60, Math.Abs(tzoffset) % 60));
            }
            break;

            case "getDaylightTimeStartDate":
            {
                GregorianDateTime vc             = new GregorianDateTime();
                string            loc_timezoneId = args.getSafe(0).getStringValue();
                int       year = (int)args.getSafe(1).getIntegerValue();
                TTimeZone tzid = TTimeZone.FindTimeZoneByName(loc_timezoneId);
                tzid.GetDaylightTimeStartDate(year, ref vc);
                result = vc;
            }
            break;

            case "getNormalTimeStartDate":
            {
                GregorianDateTime vc             = new GregorianDateTime();
                string            loc_timezoneId = args.getSafe(0).getStringValue();
                int       year = (int)args.getSafe(1).getIntegerValue();
                TTimeZone tzid = TTimeZone.FindTimeZoneByName(loc_timezoneId);
                tzid.GetNormalTimeStartDate(year, ref vc);
                result = vc;
            }
            break;

            default:
                result = base.ExecuteMessage(token, args);
                break;
            }

            return(result);
        }
示例#4
0
 public string GetDateText()
 {
     return(string.Format("{0:00} {1} {2} {3}", date.day, GregorianDateTime.GetMonthAbreviation(date.month),
                          date.year, GCCalendar.GetWeekdayAbbr(date.dayOfWeek)));
 }
示例#5
0
        public static string GetTypeString(int nType, int nData)
        {
            switch (nType)
            {
            case CoreEventType.CCTYPE_ASCENDENT:
                return("Ascendent " + GCRasi.GetName(nData));

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            default:
                return(string.Format("Unspecified event {0} / {1}", nType, nData));
            }
        }
示例#6
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++;
            }
        }
示例#7
0
        public GCConfigRatedEvents()
        {
            int i;

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

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

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

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

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

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

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

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

            FileName = null;
        }