Example #1
0
        public static string GetParanaReasonText(int eparana_type)
        {
            switch (eparana_type)
            {
            case CoreEventType.CCTYPE_THIRD_OF_DAY:
                return(GCStrings.Localized("1/3 of daylight"));

            case CoreEventType.CCTYPE_TITHI_QUARTER:
                return(GCStrings.Localized("1/4 of tithi"));

            case CoreEventType.CCTYPE_S_RISE:
                return(GCStrings.Localized("sunrise"));

            case CoreEventType.CCTYPE_TITHI_END:
                return(GCStrings.Localized("end of tithi"));

            case CoreEventType.CCTYPE_NAKS_END:
                return(GCStrings.Localized("end of naksatra"));

            default:
                break;
            }

            return("");
        }
Example #2
0
        public static void SaveInstanceData()
        {
            SaveApplicationSettings(ApplicationSettingsFilePath);

            if (TLocationDatabase.Modified)
            {
                TLocationDatabase.SaveFile(LocationsFilePath);
            }

            if (TCountry.IsModified())
            {
                TCountry.SaveFile(CountriesFilePath);
            }

            if (GCStrings.gstr_Modified)
            {
                GCStrings.SaveStringsFile(StringsFilePath);
            }

            GCDisplaySettings.SaveDisplaySettingsFile(DisplaySettingsFilePath);

            GCFestivalBookCollection.SaveAllChangedFestivalBooks(ConfigurationFolderPath);

            if (TTimeZone.Modified)
            {
                TTimeZone.SaveFile(TimezonesFilePath);
            }
        }
Example #3
0
 public string GetCoreEventTime(TCoreEvent tce)
 {
     return(GregorianDateTime.TimeSpanToLongString(tce.GetDstTime(this.BiasMinutes * 60) - this.UtcDayStart)
            + " ("
            + GCStrings.GetDSTSignature(tce.nDst * this.BiasMinutes)
            + ")");
 }
Example #4
0
 public override string ToString()
 {
     return(string.Format("{0}: {1}  {2}: {3}  {4}: {5}",
                          GCStrings.getString(10), GCEarthData.GetTextLatitude(latitudeDeg),
                          GCStrings.getString(11), GCEarthData.GetTextLongitude(longitudeDeg),
                          GCStrings.Localized("Timezone"), TTimeZone.GetTimeZoneOffsetText(OffsetUtcHours)));
 }
Example #5
0
 public string GetFullName()
 {
     return(string.Format("{0} ({1}, {2}, {3}: {4})"
                          , Title
                          , GCEarthData.GetTextLatitude(Latitude)
                          , GCEarthData.GetTextLongitude(Longitude)
                          , GCStrings.Localized("Timezone")
                          , TimeZoneName));
 }
Example #6
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);
        }
Example #7
0
 public string GetExtraFastingNote()
 {
     if (HasExtraFastingNote())
     {
         if (nMahadvadasiID == MahadvadasiType.EV_NULL)
         {
             return(GCStrings.getString(58));
         }
         else
         {
             return(GCStrings.getString(59));
         }
     }
     return("");
 }
Example #8
0
        protected void CalculateSankrantis()
        {
            VAISNAVADAY targetDay = null;

            foreach (VAISNAVADAY today in m_pData)
            {
                targetDay = null;
                int n = 0;
                foreach (TCoreEvent ce in today.coreEvents)
                {
                    switch (ce.nType)
                    {
                    case CoreEventType.CCTYPE_SANK:
                        switch (GCSankranti.GetSankrantiType())
                        {
                        case 0: targetDay = today; break;

                        case 1: targetDay = (n >= 1 ? today : today.Previous); break;

                        case 2: targetDay = (n >= 2 ? today.Next : today); break;

                        case 3: targetDay = (n >= 3 ? today.Next : today); break;
                        }
                        if (targetDay != null)
                        {
                            targetDay.sankranti_day    = today.GetGregorianDateTime(ce);
                            targetDay.sankranti_zodiac = ce.nData;
                        }
                        break;

                    case CoreEventType.CCTYPE_S_RISE: n = 1; break;

                    case CoreEventType.CCTYPE_S_NOON: n = 2; break;

                    case CoreEventType.CCTYPE_S_SET:  n = 3; break;
                    }

                    if (targetDay != null)
                    {
                        string        str = targetDay.Format(GCStrings.Localized("  {sankranti.rasiName} Sankranti (Sun enters {sankranti.rasiNameEn} on {sankranti.day} {sankranti.monthAbr}, {sankranti.hour}:{sankranti.minRound}) ({dstSig})"));
                        VAISNAVAEVENT dc  = targetDay.AddEvent(DisplayPriorities.PRIO_SANKRANTI, GCDS.CAL_SANKRANTI, str);
                        dc.spec = "sankranti";
                        break;
                    }
                }
            }
        }
Example #9
0
        public static void LoadInstanceData()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            // initialization for AppDir
            initFolders();

            // initialization of global strings
            GCStrings.LoadStringsFile(StringsFilePath);

            // inicializacia timezones
            TTimeZone.LoadFile(TimezonesFilePath);

            // inicializacia countries
            TCountry.LoadFile(CountriesFilePath);

            // inicializacia miest a kontinentov
            // lazy loading of data
            TLocationDatabase.FileName = LocationsFilePath;
            //CLocationList.OpenFile();

            // inicializacia zobrazovanych nastaveni
            GCDisplaySettings.LoadDisplaySettingsFile(DisplaySettingsFilePath);

            // inicializacia custom events
            GCFestivalBookCollection.OpenFile(ConfigurationFolderPath);

            // looking for files *.recn
            GCConfigRatedManager.RefreshListFromDirectory(ConfigurationFolderPath);

            // initialization of global variables
            myLocation.EncodedString = GCLocation.DefaultEncodedString;

            recentLocations.Add(new GCLocation(myLocation));

            LoadApplicationSettings(ApplicationSettingsFilePath);
            // refresh fasting style after loading user settings
            //GCFestivalBook.SetOldStyleFasting(GCDisplaySettings.Current.getValue(42));

            // inicializacia tipov dna
            if (!File.Exists(TipsFilePath))
            {
                File.WriteAllText(TipsFilePath, Properties.Resources.tips);
            }
        }
Example #10
0
        //public bool GetTithiTimeRange(GCEarthData earth, out GregorianDateTime from, out GregorianDateTime to)
        //{
        //    GregorianDateTime start = new GregorianDateTime();

        //    start.Set(date);
        //    start.shour = astrodata.sunRise.TotalDays;

        //    GCTithi.GetNextTithiStart(earth, start, out to);
        //    GCTithi.GetPrevTithiStart(earth, start, out from);

        //    return true;

        //}

        //public bool GetNaksatraTimeRange(GCEarthData earth, out GregorianDateTime from, out GregorianDateTime to)
        //{
        //    GregorianDateTime start = new GregorianDateTime();

        //    start.Set(date);
        //    start.shour = astrodata.sunRise.TotalDays;

        //    GCNaksatra.GetNextNaksatra(earth, start, out to);
        //    GCNaksatra.GetPrevNaksatra(earth, start, out from);

        //    return true;
        //}

        public string GetTextEP()
        {
            string            str = string.Empty;
            GregorianDateTime e1, e2;

            e1 = GetGregorianDateTime(eparana_time1);

            if (eparana_time2 != null)
            {
                e2 = GetGregorianDateTime(eparana_time2);

                if (GCDisplaySettings.Current.getValue(50) == 1)
                {
                    str = string.Format("{0} {1} ({2}) - {3} ({4}) {5}", GCStrings.getString(60),
                                        e1.ShortTimeString(), GCEkadasi.GetParanaReasonText(eparana_time1.nType),
                                        e2.ShortTimeString(), GCEkadasi.GetParanaReasonText(eparana_time2.nType),
                                        GCStrings.GetDSTSignature(BiasMinutes));
                }
                else
                {
                    str = string.Format("{0} {1} - {2} ({3})", GCStrings.getString(60),
                                        e1.ShortTimeString(), e2.ShortTimeString(), GCStrings.GetDSTSignature(BiasMinutes));
                }
            }
            else if (eparana_time1 != null)
            {
                if (GCDisplaySettings.Current.getValue(50) == 1)
                {
                    str = string.Format("{0} {1} ({2}) {3}", GCStrings.getString(61),
                                        e1.ShortTimeString(), GCEkadasi.GetParanaReasonText(eparana_time1.nType), GCStrings.GetDSTSignature(BiasMinutes));
                }
                else
                {
                    str = string.Format("{0} {1} ({2})", GCStrings.getString(61),
                                        e1.ShortTimeString(), GCStrings.GetDSTSignature(BiasMinutes));
                }
            }
            else
            {
                str = GCStrings.getString(62);
            }
            return(str);
        }
Example #11
0
        public static string GetWeekdayName(int dow)
        {
            switch (dow)
            {
            case 0: return(GCStrings.Localized("Sunday"));

            case 1: return(GCStrings.Localized("Monday"));

            case 2: return(GCStrings.Localized("Tuesday"));

            case 3: return(GCStrings.Localized("Wednesday"));

            case 4: return(GCStrings.Localized("Thursday"));

            case 5: return(GCStrings.Localized("Friday"));

            case 6: return(GCStrings.Localized("Saturday"));
            }
            return("");
        }
Example #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dow">from range 0..6</param>
        /// <returns></returns>
        public static string GetWeekdayAbbr(int dow)
        {
            switch (dow)
            {
            case 0: return(GCStrings.Localized("Su"));

            case 1: return(GCStrings.Localized("Mo"));

            case 2: return(GCStrings.Localized("Tu"));

            case 3: return(GCStrings.Localized("We"));

            case 4: return(GCStrings.Localized("Th"));

            case 5: return(GCStrings.Localized("Fr"));

            case 6: return(GCStrings.Localized("Sa"));
            }
            return("");
        }
Example #13
0
        private void CalculateKsayaVriddhiTithis()
        {
            GCEarthData earth = m_Location.GetEarthData();

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

                if (s == null)
                {
                    continue;
                }

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

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

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

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

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

            case "Time":
                return(Time);

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

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

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

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

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

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

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

            default:
                return(base.GetPropertyValue(s));
            }
        }
Example #15
0
        public string HumanDstText()
        {
            string ret;

            if (BiasMinutes == 0)
            {
                ret = GCStrings.getString(807);
            }
            else
            {
                ret = GCStrings.getString(808);
                // pre datumovy den
                if (StartDst.Type == 1)
                {
                    ret += string.Format("from {0} {1} ", GCStrings.getString(810 + StartDst.Day), GCStrings.getString(794 + StartDst.Month));
                }
                else
                {
                    // pre tyzdenny den
                    ret += string.Format("from {0} {1} {2} ", GCStrings.getString(781 + StartDst.Week), GCStrings.getString(787 + StartDst.Day),
                                         GCStrings.getString(794 + StartDst.Month));
                }

                if (EndDst.Type == 1)
                {
                    ret += string.Format("to {0} {1}", GCStrings.getString(810 + EndDst.Day), GCStrings.getString(794 + EndDst.Month));
                }
                else
                {
                    // pre tyzdenny den
                    ret += string.Format("to {0} {1} {2}", GCStrings.getString(781 + EndDst.Week),
                                         GCStrings.getString(787 + EndDst.Day), GCStrings.getString(794 + EndDst.Month));
                }
            }

            return(ret);
        }
Example #16
0
        public static string GetMahadvadasiName(int i)
        {
            switch (i)
            {
            case MahadvadasiType.EV_NULL:
            case MahadvadasiType.EV_SUDDHA:
                return(null);

            case MahadvadasiType.EV_UNMILANI:
                return(GCStrings.Localized("Unmilani Mahadvadasi"));

            case MahadvadasiType.EV_TRISPRSA:
            case MahadvadasiType.EV_UNMILANI_TRISPRSA:
                return(GCStrings.Localized("Trisprsa Mahadvadasi"));

            case MahadvadasiType.EV_PAKSAVARDHINI:
                return(GCStrings.Localized("Paksa vardhini Mahadvadasi"));

            case MahadvadasiType.EV_JAYA:
                return(GCStrings.Localized("Jaya Mahadvadasi"));

            case MahadvadasiType.EV_VIJAYA:
                return(GCStrings.Localized("Vijaya Mahadvadasi"));

            case MahadvadasiType.EV_PAPA_NASINI:
                return(GCStrings.Localized("Papa Nasini Mahadvadasi"));

            case MahadvadasiType.EV_JAYANTI:
                return(GCStrings.Localized("Jayanti Mahadvadasi"));

            case MahadvadasiType.EV_VYANJULI:
                return(GCStrings.Localized("Vyanjuli Mahadvadasi"));

            default:
                return("(Unknown Mahadvadasi)");
            }
        }
Example #17
0
 public override string ToString()
 {
     return(string.Format("{0}, Fast:{1}, Tithi:{2}, Masa:{3}", date.ToString(), GCStrings.GetFastingName(this.nFastID), GCTithi.GetName(this.astrodata.sunRise.Tithi),
                          GCMasa.GetName(astrodata.Masa)));
 }
Example #18
0
 public static string GetSankMethodName(int i)
 {
     return(GCStrings.Localized(snam[i]));
 }
Example #19
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);
        }
Example #20
0
 public static string GetMuhurtaName(int i)
 {
     return(GCStrings.Localized(p_muhurtaName[i % 30]));
 }
Example #21
0
        public static int writeGaurabdaNextTithiXml(string fileName, GCLocation loc, GregorianDateTime vcStart, GaurabdaDate vaStart)
        {
            int        gmasa, gpaksa, gtithi;
            GCHourTime sunRise;

            using (StreamWriter xml = new StreamWriter(fileName))
            {
                gmasa  = vaStart.masa;
                gpaksa = vaStart.tithi / 15;
                gtithi = vaStart.tithi % 15;

                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"Tithi\" version=\"");
                xml.Write(GCStrings.getString(130));
                xml.Write("\">\n");
                xml.Write("\t\t<arg name=\"longitude\" val=\"");
                xml.Write(loc.Longitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"latitude\" val=\"");
                xml.Write(loc.Latitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"timezone\" val=\"");
                xml.Write(loc.OffsetUtcHours);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"start date\" val=\"");
                xml.Write(vcStart);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"masa\" val=\"");
                xml.Write(gmasa);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"paksa\" val=\"");
                xml.Write(gpaksa);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"tithi\" val=\"");
                xml.Write(gtithi);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Tithi\">\n");

                GCEarthData       earth = loc.GetEarthData();
                GregorianDateTime vcs = new GregorianDateTime(), vce = new GregorianDateTime(), today = new GregorianDateTime();
                //GCSunData sun = new GCSunData();
                int         A;
                double      sunrise;
                GCAstroData day = new GCAstroData();
                int         oTithi, oPaksa, oMasa, oYear;

                today.Set(vcStart);
                today.PreviousDay();
                vcStart.SubtractDays(15);
                for (A = 0; A <= 3; A++)
                {
                    vcs.Set(GCTithi.CalcTithiEndEx(vcStart, 0, gmasa, gpaksa, gtithi, earth, out vce));
                    if (!vcs.IsBeforeThis(today))
                    {
                        oTithi = gpaksa * 15 + gtithi;
                        oMasa  = gmasa;
                        oPaksa = gpaksa;
                        oYear  = 0;
                        xml.Write("\t<celebration\n");
                        //		xml.Write("\t\t<tithi\n";
                        xml.Write("\t\trtithi=\"");
                        xml.Write(GCTithi.GetName(oTithi));
                        xml.Write("\"\n");
                        xml.Write("\t\trmasa=\"");
                        xml.Write(GCMasa.GetName(oMasa));
                        xml.Write("\"\n");
                        xml.Write("\t\trpaksa=\"");
                        xml.Write((oPaksa != 0 ? "Gaura" : "Krsna"));
                        xml.Write("\"\n");
                        // test ci je ksaya
                        today.Set(vcs);
                        today.shour = 0.5;
                        sunRise     = GCSunData.CalcSunrise(today, earth);
                        sunrise     = sunRise.TotalDays;
                        if (sunrise < vcs.shour)
                        {
                            today.Set(vce);
                            sunRise = GCSunData.CalcSunrise(today, earth);
                            sunrise = sunRise.TotalDays;
                            if (sunrise < vce.shour)
                            {
                                // normal type
                                vcs.NextDay();
                                xml.Write("\t\ttype=\"normal\"\n");
                            }
                            else
                            {
                                // ksaya
                                vcs.NextDay();
                                day.DayCalc(vcs, earth);
                                oTithi = day.sunRise.Tithi;
                                oPaksa = day.sunRise.Paksa;
                                oMasa  = day.MasaCalc(vcs, earth);
                                oYear  = day.GaurabdaYear;
                                xml.Write("\t\ttype=\"ksaya\"\n");
                            }
                        }
                        else
                        {
                            // normal, alebo prvy den vriddhi
                            today.Set(vce);
                            sunRise = GCSunData.CalcSunrise(today, earth);
                            if (sunRise.TotalDays < vce.shour)
                            {
                                // first day of vriddhi type
                                xml.Write("\t\ttype=\"vriddhi\"\n");
                            }
                            else
                            {
                                // normal
                                xml.Write("\t\ttype=\"normal\"\n");
                            }
                        }
                        xml.Write("\t\tdate=\"");
                        xml.Write(vcs);
                        xml.Write("\"\n");
                        xml.Write("\t\totithi=\"");
                        xml.Write(GCTithi.GetName(oTithi));
                        xml.Write("\"\n");
                        xml.Write("\t\tomasa=\"");
                        xml.Write(GCMasa.GetName(oMasa));
                        xml.Write("\"\n");
                        xml.Write("\t\topaksa=\"");
                        xml.Write(GCPaksa.GetName(oPaksa));
                        xml.Write("\"\n");
                        xml.Write("\t/>\n");
                        break;
                    }
                    else
                    {
                        vcStart.Set(vcs);
                        vcs.NextDay();
                    }
                }

                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }

            return(1);
        }
Example #22
0
        public static int writeGaurabdaTithiXml(string fileName, GCLocation loc, GaurabdaDate vaStart, GaurabdaDate vaEnd)
        {
            int gyearA = vaStart.gyear;
            int gyearB = vaEnd.gyear;
            int gmasa  = vaStart.masa;
            int gpaksa = vaStart.tithi / 15;
            int gtithi = vaStart.tithi % 15;

            if (gyearB < gyearA)
            {
                gyearB = gyearA;
            }

            using (StreamWriter xml = new StreamWriter(fileName))
            {
                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"Tithi\" version=\"");
                xml.Write(GCStrings.getString(130));
                xml.Write("\">\n");
                xml.Write("\t\t<arg name=\"longitude\" val=\"");
                xml.Write(loc.Longitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"latitude\" val=\"");
                xml.Write(loc.Latitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"timezone\" val=\"");
                xml.Write(loc.OffsetUtcHours);
                xml.Write("\" />\n");
                if (gyearA > 1500)
                {
                    xml.Write("\t\t<arg name=\"year-start\" val=\"");
                    xml.Write(gyearA);
                    xml.Write("\" />\n");
                    xml.Write("\t\t<arg name=\"year-end\" val=\"");
                    xml.Write(gyearB);
                    xml.Write("\" />\n");
                }
                else
                {
                    xml.Write("\t\t<arg name=\"gaurabdayear-start\" val=\"");
                    xml.Write(gyearA);
                    xml.Write("\" />\n");
                    xml.Write("\t\t<arg name=\"gaurabdayear-end\" val=\"");
                    xml.Write(gyearB);
                    xml.Write("\" />\n");
                }
                xml.Write("\t\t<arg name=\"masa\" val=\"");
                xml.Write(gmasa);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"paksa\" val=\"");
                xml.Write(gpaksa);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"tithi\" val=\"");
                xml.Write(gtithi);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Tithi\">\n");


                GCEarthData       earth = loc.GetEarthData();
                GregorianDateTime vcs = new GregorianDateTime(), vce = new GregorianDateTime(), today = new GregorianDateTime();
                GCHourTime        sun = new GCHourTime();
                int         A, B;
                double      sunrise;
                GCAstroData day = new GCAstroData();
                int         oTithi, oPaksa, oMasa, oYear;

                if (gyearA > 1500)
                {
                    A = gyearA - 1487;
                    B = gyearB - 1485;
                }
                else
                {
                    A = gyearA;
                    B = gyearB;
                }

                for (; A <= B; A++)
                {
                    vcs.Set(GCTithi.CalcTithiEnd(A, gmasa, gpaksa, gtithi, earth, out vce));
                    if (gyearA > 1500)
                    {
                        if ((vcs.year < gyearA) || (vcs.year > gyearB))
                        {
                            continue;
                        }
                    }
                    oTithi = gpaksa * 15 + gtithi;
                    oMasa  = gmasa;
                    oPaksa = gpaksa;
                    oYear  = 0;
                    xml.Write("\t<celebration\n");
                    //		xml.Write("\t\t<tithi\n";
                    xml.Write("\t\trtithi=\"");
                    xml.Write(GCTithi.GetName(oTithi));
                    xml.Write("\"\n");
                    xml.Write("\t\trmasa=\"");
                    xml.Write(GCMasa.GetName(oMasa));
                    xml.Write("\"\n");
                    xml.Write("\t\trpaksa=\"");
                    xml.Write(oPaksa != 0 ? "Gaura" : "Krsna");
                    xml.Write("\"\n");
                    // test ci je ksaya
                    today.Set(vcs);
                    today.shour = 0.5;
                    sun         = GCSunData.CalcSunrise(today, earth);
                    sunrise     = sun.TotalDays;
                    if (sunrise < vcs.shour)
                    {
                        today.Set(vce);
                        sun     = GCSunData.CalcSunrise(today, earth);
                        sunrise = sun.TotalDays;
                        if (sunrise < vce.shour)
                        {
                            // normal type
                            vcs.NextDay();
                            xml.Write("\t\ttype=\"normal\"\n");
                        }
                        else
                        {
                            // ksaya
                            vcs.NextDay();
                            day.DayCalc(vcs, earth);
                            oTithi = day.sunRise.Tithi;
                            oPaksa = day.sunRise.Paksa;
                            oMasa  = day.MasaCalc(vcs, earth);
                            oYear  = day.GaurabdaYear;
                            xml.Write("\t\ttype=\"ksaya\"\n");
                        }
                    }
                    else
                    {
                        // normal, alebo prvy den vriddhi
                        today.Set(vce);
                        sun = GCSunData.CalcSunrise(today, earth);
                        if (sun.TotalDays < vce.shour)
                        {
                            // first day of vriddhi type
                            xml.Write("\t\ttype=\"vriddhi\"\n");
                        }
                        else
                        {
                            // normal
                            xml.Write("\t\ttype=\"normal\"\n");
                        }
                    }
                    xml.Write("\t\tdate=\"");
                    xml.Write(vcs);
                    xml.Write("\"\n");
                    xml.Write("\t\totithi=\"");
                    xml.Write(GCTithi.GetName(oTithi));
                    xml.Write("\"\n");
                    xml.Write("\t\tomasa=\"");
                    xml.Write(GCMasa.GetName(oMasa));
                    xml.Write("\"\n");
                    xml.Write("\t\topaksa=\"");
                    xml.Write(GCPaksa.GetName(oPaksa));
                    xml.Write("\"\n");
                    xml.Write("\t/>\n");
                }

                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }
            return(1);
        }
Example #23
0
        public static int writeXml(string fileName, GCLocation loc, GregorianDateTime vc)
        {
            String            str;
            GregorianDateTime date;

            using (StreamWriter xml = new StreamWriter(fileName))
            {
                xml.Write("<xml>\n");
                xml.Write("\t<request name=\"Tithi\" version=\"");
                xml.Write(GCStrings.getString(130));
                xml.Write("\">\n");
                xml.Write("\t\t<arg name=\"longitude\" val=\"");
                xml.Write(loc.Longitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"latitude\" val=\"");
                xml.Write(loc.Latitude);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"timezone\" val=\"");
                xml.Write(loc.OffsetUtcHours);
                xml.Write("\" />\n");
                xml.Write("\t\t<arg name=\"startdate\" val=\"");
                xml.Write(vc);
                xml.Write("\" />\n");
                xml.Write("\t</request>\n");
                xml.Write("\t<result name=\"Tithi\">\n");

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


                GCAstroData day = new GCAstroData();

                day.DayCalc(vc, earth);

                d.shour = day.sunRise.TotalDays;

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

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

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

                xml.Write("\t</result>\n");
                xml.Write("</xml>\n");
            }
            return(1);
        }
Example #24
0
 /// <summary>
 /// Retrieves name of tithi
 /// </summary>
 /// <param name="nTithi">Values 0..29, where 0 is for Pratipat in Krsna Paksa</param>
 /// <returns></returns>
 public static string GetName(int nTithi)
 {
     return(GCStrings.Localized(p_tithiName[nTithi % 30]));
 }
Example #25
0
        public string Format(string format, params string[] args)
        {
            StringBuilder sb = new StringBuilder(format);

            if (format.IndexOf("{day}") >= 0)
            {
                format = format.Replace("{day}", date.day.ToString());
            }
            if (format.IndexOf("{month}") >= 0)
            {
                format = format.Replace("{month}", date.month.ToString());
            }
            if (format.IndexOf("{monthAbr}") >= 0)
            {
                format = format.Replace("{monthAbr}", GregorianDateTime.GetMonthName(date.month));
            }
            if (format.IndexOf("{monthName}") >= 0)
            {
                format = format.Replace("{monthName}", GregorianDateTime.GetMonthName(date.month));
            }
            if (format.IndexOf("{year}") >= 0)
            {
                format = format.Replace("{year}", date.year.ToString());
            }
            if (format.IndexOf("{hour}") >= 0)
            {
                format = format.Replace("{hour}", date.GetHour().ToString("D2"));
            }
            if (format.IndexOf("{min}") >= 0)
            {
                format = format.Replace("{min}", date.GetMinute().ToString("D2"));
            }
            if (format.IndexOf("{minRound}") >= 0)
            {
                format = format.Replace("{minRound}", date.GetMinuteRound().ToString("D2"));
            }
            if (format.IndexOf("{sec}") >= 0)
            {
                format = format.Replace("{sec}", date.GetSecond().ToString("D2"));
            }

            if (format.IndexOf("{masaName}") >= 0)
            {
                format = format.Replace("{masaName}", GCMasa.GetName(astrodata.Masa));
            }
            if (format.IndexOf("{gaurabdaYear}") >= 0)
            {
                format = format.Replace("{gaurabdaYear}", astrodata.GaurabdaYear.ToString());
            }
            if (format.IndexOf("{tithiName}") >= 0)
            {
                format = format.Replace("{tithiName}", GCTithi.GetName(astrodata.sunRise.Tithi));
            }
            if (format.IndexOf("{prevTithiName}") >= 0)
            {
                format = format.Replace("{prevTithiName}", GCTithi.GetName((astrodata.sunRise.Tithi + 29) % 30));
            }
            if (format.IndexOf("{nextTithiName}") >= 0)
            {
                format = format.Replace("{nextTithiName}", GCTithi.GetName((astrodata.sunRise.Tithi + 1) % 30));
            }
            if (format.IndexOf("{paksaName}") >= 0)
            {
                format = format.Replace("{paksaName}", GCPaksa.GetName(astrodata.sunRise.Paksa));
            }
            if (format.IndexOf("{yogaName}") >= 0)
            {
                format = format.Replace("{yogaName}", GCYoga.GetName(astrodata.sunRise.Yoga));
            }
            if (format.IndexOf("{naksatraName}") >= 0)
            {
                format = format.Replace("{naksatraName}", GCNaksatra.GetName(astrodata.sunRise.Naksatra));
            }
            if (format.IndexOf("{naksatraElapse}") >= 0)
            {
                format = format.Replace("{naksatraElapse}", astrodata.sunRise.NaksatraElapse.ToString("P2"));
            }
            if (format.IndexOf("{naksatraPada}") >= 0)
            {
                format = format.Replace("{naksatraPada}", GCNaksatra.GetPadaText(astrodata.sunRise.NaksatraPada));
            }

            if (format.IndexOf("{sankranti.day}") >= 0)
            {
                format = format.Replace("{sankranti.day}", sankranti_day.day.ToString());
            }
            if (format.IndexOf("{sankranti.month}") >= 0)
            {
                format = format.Replace("{sankranti.month}", sankranti_day.month.ToString());
            }
            if (format.IndexOf("{sankranti.monthAbr}") >= 0)
            {
                format = format.Replace("{sankranti.monthAbr}", GregorianDateTime.GetMonthName(sankranti_day.month));
            }
            if (format.IndexOf("{sankranti.monthName}") >= 0)
            {
                format = format.Replace("{sankranti.monthName}", GregorianDateTime.GetMonthName(sankranti_day.month));
            }
            if (format.IndexOf("{sankranti.hour}") >= 0)
            {
                format = format.Replace("{sankranti.hour}", sankranti_day.GetHour().ToString("D2"));
            }
            if (format.IndexOf("{sankranti.min}") >= 0)
            {
                format = format.Replace("{sankranti.min}", sankranti_day.GetMinute().ToString("D2"));
            }
            if (format.IndexOf("{sankranti.minRound}") >= 0)
            {
                format = format.Replace("{sankranti.minRound}", sankranti_day.GetMinuteRound().ToString("D2"));
            }
            if (format.IndexOf("{sankranti.sec}") >= 0)
            {
                format = format.Replace("{sankranti.sec}", sankranti_day.GetSecond().ToString("D2"));
            }
            if (format.IndexOf("{sankranti.rasiNameEn}") >= 0)
            {
                format = format.Replace("{sankranti.rasiNameEn}", GCRasi.GetNameEn(sankranti_zodiac));
            }
            if (format.IndexOf("{sankranti.rasiName}") >= 0)
            {
                format = format.Replace("{sankranti.rasiName}", GCRasi.GetName(sankranti_zodiac));
            }

            if (format.IndexOf("{dstSig}") >= 0)
            {
                format = format.Replace("{dstSig}", GCStrings.GetDSTSignature(BiasMinutes));
            }

            if (format.IndexOf("{moonRiseTime}") >= 0)
            {
                format = format.Replace("{moonRiseTime}", moonrise.ToShortTimeString());
            }
            if (format.IndexOf("{moonSetTime}") >= 0)
            {
                format = format.Replace("{moonSetTime}", moonset.ToShortTimeString());
            }
            if (format.IndexOf("{moonRasiName}") >= 0)
            {
                format = format.Replace("{moonRasiName}", GCRasi.GetName(astrodata.sunRise.RasiOfMoon));
            }
            if (format.IndexOf("{moonRasiNameEn}") >= 0)
            {
                format = format.Replace("{moonRasiNameEn}", GCRasi.GetNameEn(astrodata.sunRise.RasiOfMoon));
            }

            if (args == null || args.Length == 0)
            {
                return(format.ToString());
            }
            else
            {
                return(string.Format(format.ToString(), args));
            }
        }
Example #26
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));
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="month">Month from range 1..12</param>
 /// <returns></returns>
 public static string GetMonthAbreviation(int month)
 {
     return(GCStrings.Localized(p_monthNameAbbr[(month - 1) % 12]));
 }
Example #28
0
        public void ResolveFestivalsFasting(int nIndex)
        {
            VAISNAVADAY s = m_pData[nIndex - 1];
            VAISNAVADAY t = m_pData[nIndex];
            VAISNAVADAY u = m_pData[nIndex + 1];

            String        str;
            String        subject      = string.Empty;
            int           fastForDay   = 0;
            int           fastForEvent = 0;
            string        ch;
            VAISNAVAEVENT md;

            if (t.nMahadvadasiID != MahadvadasiType.EV_NULL)
            {
                str = string.Format(GCStrings.Localized("Fasting for {0}"), t.ekadasi_vrata_name);
                t.AddEvent(DisplayPriorities.PRIO_EKADASI, GCDS.CAL_EKADASI_PARANA, str);
            }

            ch = GCEkadasi.GetMahadvadasiName((int)t.nMahadvadasiID);
            if (ch != null)
            {
                t.AddEvent(DisplayPriorities.PRIO_MAHADVADASI, GCDS.CAL_EKADASI_PARANA, ch);
            }

            if (t.ekadasi_parana)
            {
                str = t.GetTextEP();
                t.AddEvent(DisplayPriorities.PRIO_EKADASI_PARANA, GCDS.CAL_EKADASI_PARANA, str);
            }

            for (int h = 0; h < t.dayEvents.Count(); h++)
            {
                md           = t.dayEvents[h];
                fastForEvent = FastType.FAST_NULL;
                if (md.fasttype != FastType.FAST_NULL)
                {
                    fastForEvent = md.fasttype;
                    subject      = md.fastsubject;
                }

                if (fastForEvent != FastType.FAST_NULL)
                {
                    if (s.nFastID == FastType.FAST_EKADASI)
                    {
                        if (GCDisplaySettings.Current.getValue(42) == 0)
                        {
                            str = string.Format(GCStrings.Localized("(Fast today for {0})"), subject);
                            s.AddEvent(DisplayPriorities.PRIO_FASTING, GCDS.DISP_ALWAYS, str);
                            t.AddEvent(md.prio + 1, md.dispItem, GCStrings.Localized("(Fasting is done yesterday)"));
                            //"(Fasting is done yesterday)"
                        }
                        else
                        {
                            str = string.Format(GCStrings.Localized("(Fast till noon for {0}, with feast tomorrow)"), subject);
                            s.AddEvent(DisplayPriorities.PRIO_FASTING, GCDS.DISP_ALWAYS, str);
                            t.AddEvent(md.prio + 1, md.dispItem, GCStrings.Localized("(Fasting is done yesterday, today is feast)"));
                            //"(Fasting is done yesterday, today is feast)";
                        }
                    }
                    else if (t.nFastID == FastType.FAST_EKADASI)
                    {
                        if (GCDisplaySettings.Current.getValue(42) != 0)
                        {
                            t.AddEvent(md.prio + 1, md.dispItem, GCStrings.Localized("(Fasting till noon, with feast tomorrow)"));
                        }
                        //"(Fasting till noon, with feast tomorrow)";
                        else
                        {
                            t.AddEvent(md.prio + 1, md.dispItem, GCStrings.Localized("(Fast today)"));
                        }
                        //"(Fast today)"
                    }
                    else
                    {
                        /* OLD STYLE FASTING
                         * if (GCDisplaySettings.Current.getValue(42) == 0)
                         * {
                         *  if (nftype > 1)
                         *      nftype = 7;
                         *  else nftype = 0;
                         * }*/
                        if (fastForEvent != FastType.FAST_NULL)
                        {
                            t.AddEvent(md.prio + 1, md.dispItem,
                                       GCStrings.GetFastingName(fastForEvent));
                        }
                    }
                }
                if (fastForDay < fastForEvent)
                {
                    fastForDay = fastForEvent;
                }
            }

            if (fastForDay != FastType.FAST_NULL)
            {
                if (s.nFastID == FastType.FAST_EKADASI)
                {
                    t.nFeasting = FeastType.FEAST_TODAY_FAST_YESTERDAY;
                    s.nFeasting = FeastType.FEAST_TOMMOROW_FAST_TODAY;
                }
                else if (t.nFastID == FastType.FAST_EKADASI)
                {
                    u.nFeasting = FeastType.FEAST_TODAY_FAST_YESTERDAY;
                    t.nFeasting = FeastType.FEAST_TOMMOROW_FAST_TODAY;
                }
                else
                {
                    t.nFastID = fastForDay;
                }
            }
        }
        public static void Export(string pszFile, int format)
        {
            String strc;

            using (StreamWriter f = new StreamWriter(pszFile))
            {
                foreach (GCFestivalBook book in GCFestivalBookCollection.Books)
                {
                    switch (format)
                    {
                    case 1:
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("{0}\n\t{1} Tithi,{2} Paksa,{3} Masa\n", pce.Text,
                                                     GCTithi.GetName(pce.nTithi), GCPaksa.GetName(pce.nTithi / 15), GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                                if (pce.FastID != 0)
                                {
                                    strc = string.Format("\t{0}\n", GCStrings.GetFastingName(pce.FastID));
                                    f.Write(strc);
                                }
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write(string.Format("{0}\n\t\t{1} Sankranti, {2}\n", se.Text, GCRasi.GetName(se.RasiOfSun), se.DayOffset));
                            }
                        }

                        break;

                    case 2:
                    {
                        f.Write("<xml>\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t<event>\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                strc = string.Format("\t\t<name>{0}</name>\n", pce.Text);
                                f.Write(strc);
                                strc = string.Format("\t\t<tithi>{0}</tithi>\n", GCTithi.GetName(pce.nTithi));
                                f.Write(strc);
                                strc = string.Format("\t\t<paksa>{0}</paksa>\n", GCPaksa.GetName(pce.nTithi / 15));
                                f.Write(strc);
                                strc = string.Format("\t\t<masa>{0}</masa>\n", GCMasa.GetName(pce.nMasa));
                                f.Write(strc);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t<name>" + se.Text + "</name>\n");
                                f.Write("\t\t<sankranti>" + GCRasi.GetName(se.RasiOfSun) + "</sankranti>\n");
                                f.Write("\t\t<rel>" + se.DayOffset + "</rel>\n");
                            }

                            if (fb.EventsCount > 0)
                            {
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t<relatedEvent>\n");
                                        f.Write("\t\t\t<name>" + rel.Text + "</name>\n");
                                        f.Write("\t\t\t<offset>" + rel.DayOffset + "</offset>\n");
                                        f.Write("\t\t</relatedEvent>\n");
                                    }
                                }
                            }

                            f.Write("\t</event>\n");
                        }

                        f.Write("</xml>\n");
                    }
                    break;

                    case 3:
                        GSScript script = new GSScript();
                        script.Add(new GSToken("book"));
                        script.Add(new GSList(new GSToken("bookId"), new GSNumber(book.CollectionId)));
                        script.Add(new GSList(new GSToken("bookName"), new GSString(book.CollectionName)));
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            script.Add(fb.ExecuteMessage("getScript"));
                        }
                        script.writeScript(f);
                        break;

                    case 15:
                    {
                        f.Write("{\n");
                        f.Write("\tname: \"" + book.CollectionName + "\",\n");
                        f.Write("\tbookid: " + book.CollectionId + ",\n");
                        f.Write("\tevents: [\n");
                        foreach (GCFestivalBase fb in book.Festivals)
                        {
                            f.Write("\t\t{\n");
                            if (fb is GCFestivalTithiMasa)
                            {
                                GCFestivalTithiMasa pce = fb as GCFestivalTithiMasa;
                                f.Write("\t\t\ttype: \"T\",\n");
                                f.Write("\t\t\tname: \"{0}\",\n", pce.Text);
                                f.Write("\t\t\ttithi: {0},\n", pce.nTithi);
                                f.Write("\t\t\tmasa: {0}\n", pce.nMasa);
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", pce.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", pce.FastID);
                                f.Write("\t\t\tstart: {0},\n", pce.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", pce.DayOffset);
                            }
                            else if (fb is GCFestivalSankranti)
                            {
                                GCFestivalSankranti se = fb as GCFestivalSankranti;
                                f.Write("\t\t\ttype:\"S\",\n");
                                f.Write("\t\t\tname: \"" + se.Text + "\",\n");
                                f.Write("\t\t\tsankranti: " + se.RasiOfSun + ",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }
                            else if (fb is GCFestivalSpecial)
                            {
                                GCFestivalSpecial spe = fb as GCFestivalSpecial;
                                f.Write("\t\t\ttype: \"X\",\n");
                                f.Write("\t\t\tname: \"" + spe.Text + "\",\n");
                                f.Write("\t\t\tmasa1: " + spe.nMasaMin + ",\n");
                                f.Write("\t\t\tmasa2: " + spe.nMasaMax + ",\n");
                                f.Write("\t\t\tscript: \"" + spe.Script + "\",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }
                            else if (fb is GCFestivalEkadasi)
                            {
                                GCFestivalEkadasi se = fb as GCFestivalEkadasi;
                                f.Write("\t\t\ttype: \"E\",\n");
                                f.Write("\t\t\tname: \"" + se.Text + "\",\n");
                                f.Write("\t\t\tmasa: " + se.nMasa + ",\n");
                                f.Write("\t\t\tpaksa: " + se.nPaksa + ",\n");
                                f.Write("\t\t\tfastSubj: \"{0}\",\n", fb.FastingSubject);
                                f.Write("\t\t\tfast: {0},\n", fb.FastID);
                                f.Write("\t\t\tstart: {0},\n", fb.StartYear);
                                f.Write("\t\t\tdayoff: {0},\n", fb.DayOffset);
                            }

                            if (fb.EventsCount > 0)
                            {
                                f.Write("\t\t\tevents: [\n");
                                foreach (GCFestivalBase fb2 in fb.Events)
                                {
                                    if (fb2 is GCFestivalRelated)
                                    {
                                        GCFestivalRelated rel = fb2 as GCFestivalRelated;
                                        f.Write("\t\t\t\t{\n\t\t\t\t\ttype:\"R\",\n");
                                        f.Write("\t\t\t\t\tname: \"" + rel.Text + "\",\n");
                                        f.Write("\t\t\t\t\tfastSubj: \"{0}\",\n", fb2.FastingSubject);
                                        f.Write("\t\t\t\t\tfast: {0},\n", fb2.FastID);
                                        f.Write("\t\t\t\t\tstart: {0},\n", fb2.StartYear);
                                        f.Write("\t\t\t\t\tdayoff: {0},\n", fb2.DayOffset);
                                        f.Write("\t\t\t\t},\n");
                                    }
                                }
                                f.Write("\t\t\t]");
                            }

                            f.Write("\t\t},\n");
                        }

                        f.Write("\t]\n");
                        f.Write("},\n");
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }
Example #30
0
 public override GSCore GetPropertyValue(string Token)
 {
     if (Token.Equals("date"))
     {
         return(date);
     }
     else if (Token.Equals("astro"))
     {
         return(astrodata);
     }
     else if (Token.Equals("dateHumanName"))
     {
         return(new GSString(GregorianDateTime.GetDateTextWithTodayExt(date)));
     }
     else if (Token.Equals("nDST"))
     {
         return(new GSNumber(BiasMinutes));
     }
     else if (Token.Equals("events"))
     {
         GSList list = new GSList();
         list.Parts.AddRange(dayEvents);
         return(list);
     }
     else if (Token.Equals("visibleEvents"))
     {
         GSList list = new GSList();
         list.Parts.AddRange(VisibleEvents);
         return(list);
     }
     else if (Token.Equals("htmlDayColor"))
     {
         return(new GSString(TResultCalendar.getDayBkgColorCode(this)));
     }
     else if (Token.Equals("dstSignature"))
     {
         return(new GSString(GCStrings.GetDSTSignature(BiasMinutes)));
     }
     else if (Token.Equals("tithiNameExt"))
     {
         return(new GSString(GetFullTithiName()));
     }
     else if (Token.Equals("isWeekend"))
     {
         return(new GSBoolean(date.dayOfWeek == 6 || date.dayOfWeek == 0));
     }
     else if (Token.Equals("fastType"))
     {
         return(new GSNumber(nFastID));
     }
     else if (Token.Equals("fastTypeMark"))
     {
         return(new GSString(nFastID != 0 ? "*" : " "));
     }
     else if (Token.Equals("ekadasiParana"))
     {
         return(new GSBoolean(ekadasi_parana));
     }
     else if (Token.Equals("ekadasiParanaStart"))
     {
         return(GetGregorianDateTime(eparana_time1));
     }
     else if (Token.Equals("ekadasiParanaEnd"))
     {
         return(GetGregorianDateTime(eparana_time2));
     }
     else if (Token.Equals("hasParanaStart"))
     {
         return(new GSBoolean(eparana_time1 != null));
     }
     else if (Token.Equals("hasParanaEnd"))
     {
         return(new GSBoolean(eparana_time2 != null));
     }
     else if (Token.Equals("sankrantiZodiac"))
     {
         return(new GSNumber(sankranti_zodiac));
     }
     else if (Token.Equals("sankrantiDateTime"))
     {
         return(sankranti_day);
     }
     else if (Token.Equals("ksayaTithi"))
     {
         return(new GSNumber(ksayaTithi));
     }
     else if (Token.Equals("ksayaMasa"))
     {
         return(new GSNumber(ksayaMasa));
     }
     else
     {
         return(base.GetPropertyValue(Token));
     }
 }