Exemplo n.º 1
0
        public DayOfWeek getMonthFirstDay(int eng_year, int tamilMonthCount)
        {
            tamilMonthCount = tamilMonthCount - 1;

            YearInfo objYearInfo = _YearInfos
                                   .Where(w => w.YearNumber == eng_year)
                                   .FirstOrDefault();

            DateTime objDateTime = new DateTime(eng_year,
                                                4,
                                                objYearInfo.ChithiraiStartAprlDay);

            int TotalDays = 0;

            for (int i = 0; i < tamilMonthCount; i++)
            {
                TotalDays += objYearInfo.MonthDaysCount[i];
            }

            objDateTime = objDateTime.AddDays(TotalDays);

            //if (objDateTime.DayOfWeek == DayOfWeek.)

            return(objDateTime.DayOfWeek);
        }
Exemplo n.º 2
0
        public void setYearInfos()
        {
            _YearInfos = new List <YearInfo>();
            //_YearInfos.Add(new YearInfo
            //{
            //    YearNumber = 2018,
            //    ChithiraiStartAprlDay = 14,
            //    MonthDaysCount = new int[] { 31, 31, 32, 31, 31, 31, 30, 29, 29, 30, 30, 30 }
            //});
            string filePath = Path.GetDirectoryName(Application.ExecutablePath) + "\\YearInfo.txt";

            foreach (string line in File.ReadAllLines(filePath))
            {
                YearInfo objYearInfo    = new YearInfo();
                string[] splitedContent = line.Split(',');
                for (int i = 0; i < 14; i++)
                {
                    if (i == 0)
                    {
                        objYearInfo.YearNumber = Convert.ToInt32(splitedContent[i]);
                    }
                    else if (i == 1)
                    {
                        objYearInfo.ChithiraiStartAprlDay = Convert.ToInt32(splitedContent[i]);
                    }
                    else
                    {
                        objYearInfo.MonthDaysCount[i - 2] = Convert.ToInt32(splitedContent[i]);
                    }
                }
                _YearInfos.Add(objYearInfo);
            }

            //At last line set the MinYear and MaxYear
        }
Exemplo n.º 3
0
        public int getMonthDaysCount(int eng_year, int tamilMonthCount)
        {
            YearInfo objYearInfo = _YearInfos.Where(w => w.YearNumber == eng_year)
                                   .FirstOrDefault();

            return(objYearInfo.MonthDaysCount[tamilMonthCount]);
        }
Exemplo n.º 4
0
        public TamilDate getTamilDate(DateTime dateTime, Eras ers)
        {
            TamilDate objTodayTamilDate = new TamilDate();
            YearInfo  objYearInfo       = _YearInfos
                                          .Where(w => w.YearNumber == dateTime.Year)
                                          .FirstOrDefault();

            //Set April Month start date
            DateTime aprDateTime = new DateTime(dateTime.Year,
                                                4, objYearInfo.ChithiraiStartAprlDay);
            DateTime objTodayDateOnly        = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            double   TotalDaysFromAprilStart = (objTodayDateOnly - aprDateTime).TotalDays;


            int tamilMonthDaysCounter     = 0,
                tamilMonthDaysAntiCounter = 0;
            int tamilMonthCounter         = 0;

            //objTodayTamilDate.MonthNo = getChithiraiAprilStartDate(dateTime);
            for (int i = 0; i < objYearInfo.MonthDaysCount.Length; i++)
            {
                if (tamilMonthDaysCounter < TotalDaysFromAprilStart)
                {
                    tamilMonthDaysCounter += getMonthDaysCount(dateTime.Year, i);
                    tamilMonthCounter++;
                    if (tamilMonthDaysCounter < TotalDaysFromAprilStart)
                    {
                        tamilMonthDaysAntiCounter = Convert.ToInt16(Math.Floor(TotalDaysFromAprilStart)) - tamilMonthDaysCounter;
                        tamilMonthDaysAntiCounter++;
                    }
                }
            }

            objTodayTamilDate.tamilMonth = getTamilMonthsWithPeruPoluthu(ers)
                                           .Where(w => w.MonthNo == tamilMonthCounter)
                                           .FirstOrDefault();
            objTodayTamilDate.DayNo = tamilMonthDaysAntiCounter;

            objTodayTamilDate.tamilYear = getTamilYears(ers)
                                          .Where(w => w.yearCount == (dateTime.Year - 1986))
                                          .FirstOrDefault();

            //return ", ௨௫, ௨0௧௮";
            return(objTodayTamilDate);
        }