Exemple #1
0
        private void day_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!loadcomplete)
            {
                return;
            }
            try
            {
                nepdate = new NepDate()
                {
                    Year  = year.getSelectedItem().getdata <int>(),
                    Month = month.getSelectedItem().getvalue <int>(),
                    Day   = day.getSelectedItem().getvalue <int>()
                };

                engdate = NepDateConverter.NepToEng(nepdate);
                if (changed != null)
                {
                    changed(this, EventArgs.Empty);
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #2
0
        private void year_SelectedIndexChanged(object sender, EventArgs e)

        {
            if (!loadcomplete)
            {
                return;
            }
            try
            {
                day.Items.Clear();

                for (var i = 1; i <= NepDateConverter.getMonthDays(year.getSelectedItem().getvalue <int>(), month.getSelectedItem().getvalue <int>()); i++)
                {
                    day.addItem(i, i);
                }
                day.selectByValue(1);

                nepdate = new NepDate()
                {
                    Year  = year.getSelectedItem().getdata <int>(),
                    Month = month.getSelectedItem().getvalue <int>(),
                    Day   = day.getSelectedItem().getvalue <int>()
                };

                engdate = NepDateConverter.NepToEng(nepdate);
                if (changed != null)
                {
                    changed(this, EventArgs.Empty);
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemple #3
0
        private void NepSel_Load(object sender, EventArgs e)
        {
            foreach (var years in NepDateConverter.getAllYears())
            {
                year.addItem(years.Value, years.Key);
            }

            foreach (var months in NepDateConverter.GetMonths())
            {
                month.addItem(months.Value, months.Key);
            }

            nepdate = NepDateConverter.EngToNep(DateTime.Now);
            year.selectBydata(nepdate.Year);
            month.selectByValue(nepdate.Month);
            day.Items.Clear();

            for (var i = 1; i <= NepDateConverter.getMonthDays(year.getSelectedItem().getvalue <int>(), month.getSelectedItem().getvalue <int>()); i++)
            {
                day.addItem(i, i);
            }
            day.selectByValue(nepdate.Day);
            loadcomplete = true;
            engdate      = NepDateConverter.NepToEng(nepdate);
        }
Exemple #4
0
        public int[] getYear()
        {
            var year = new int[] { 0, 1 };

            year[0] = new NepDate(
                date.Year,
                1,
                1
                ).TIMESTAMP();
            year[1] = new NepDate(
                date.Year,
                12,
                32
                ).TIMESTAMP();
            return(year);
        }
Exemple #5
0
        public int[] getMonth()
        {
            var month = new int[] { 0, 1 };

            month[0] = new NepDate(
                date.Year,
                date.Month,
                1
                ).TIMESTAMP();
            month[1] = new NepDate(
                date.Year,
                date.Month,
                32
                ).TIMESTAMP();
            return(month);
        }
Exemple #6
0
        public int[] getWeek(int i)
        {
            var week = new int[] { 1, 0 };

            week[0] = new NepDate(
                date.Year,
                date.Month,
                (i * 7) + 1
                ).TIMESTAMP();
            week[1] = new NepDate(
                date.Year,
                date.Month,
                (i * 7) + 7
                ).TIMESTAMP();
            return(week);
        }
Exemple #7
0
        public void loadEnglishdate(DateTime dt)
        {
            if (!loadcomplete)
            {
                return;
            }
            engdate = dt;
            this.NepSel_Load(this, null);
            nepdate = NepDateConverter.EngToNep(DateTime.Now);
            year.selectBydata(nepdate.Year);
            month.selectByValue(nepdate.Month);
            day.Items.Clear();

            for (var i = 1; i <= NepDateConverter.getMonthDays(year.getSelectedItem().getvalue <int>(), month.getSelectedItem().getvalue <int>()); i++)
            {
                day.addItem(i, i);
            }
            day.selectByValue(nepdate.Day);
            if (changed != null)
            {
                changed(this, EventArgs.Empty);
            }
        }
Exemple #8
0
 public static DateTime NepToEng(NepDate dateTime)
 {
     return(NepToEng(dateTime.Year, dateTime.Month, dateTime.Day));
 }
Exemple #9
0
        public static NepDate EngToNep(int yy, int mm, int dd)
        {
            if (bs == null)
            {
                InitializeData();
            }
            if (IsRangeEng(yy, mm, dd) == false)
            {
                return(null);
            }
            else
            {
                // english month data.
                int[] month  = new int[] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
                int[] lmonth = new int[] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

                int def_eyy = 1944;                                                                     //spear head english date...
                int def_nyy = 2000;
                int def_nmm = 9;
                int def_ndd = 17 - 1;                            //spear head nepali date...
                int total_eDays = 0;
                int total_nDays = 0; int a = 0; int day = 7 - 1; //all the initializations...
                int m = 0; int y = 0; int i = 0; int j = 0;
                int numDay = 0;

                // count total no. of days in-terms of year
                for (i = 0; i < (yy - def_eyy); i++)
                {       //total days for month calculation...(english)
                    if (IsLeapYear(def_eyy + i))
                    {
                        for (j = 0; j < 12; j++)
                        {
                            total_eDays += lmonth[j];
                        }
                    }
                    else
                    {
                        for (j = 0; j < 12; j++)
                        {
                            total_eDays += month[j];
                        }
                    }
                }

                // count total no. of days in-terms of month
                for (i = 0; i < (mm - 1); i++)
                {
                    if (IsLeapYear(yy))
                    {
                        total_eDays += lmonth[i];
                    }
                    else
                    {
                        total_eDays += month[i];
                    }
                }

                // count total no. of days in-terms of date
                total_eDays += dd;


                i           = 0; j = def_nmm;
                total_nDays = def_ndd;
                m           = def_nmm;
                y           = def_nyy;

                // count nepali date from array
                while (total_eDays != 0)
                {
                    a = bs[i][j];
                    total_nDays++;                                              //count the days
                    day++;                                                      //count the days interms of 7 days
                    if (total_nDays > a)
                    {
                        m++;
                        total_nDays = 1;
                        j++;
                    }
                    if (day > 7)
                    {
                        day = 1;
                    }
                    if (m > 12)
                    {
                        y++;
                        m = 1;
                    }
                    if (j > 12)
                    {
                        j = 1; i++;
                    }
                    total_eDays--;
                }

                numDay = day;
                var nepDate = new NepDate();
                nepDate.Year        = y;
                nepDate.Month       = m;
                nepDate.Day         = total_nDays;
                nepDate.WeekDayName = GetDayOfWeek(day);
                nepDate.MonthName   = GetNepaliMonth(m);
                nepDate.WeekDay     = numDay;
                return(nepDate);
            }
        }