Пример #1
0
		public void ObtainHijriDate(DateTime dt)
		{
			var hcal = new HijriCalendar();
			HijriEventArgs args = new HijriEventArgs();
			args.year = hcal.GetYear(dt);
			args.month = hcal.GetMonth(dt);
			args.daysInMonth = hcal.GetDaysInMonth(args.year, args.month);
			args.dayOfMonth = hcal.GetDayOfMonth(dt);

			//start date of same month in hijri
			var sdt = dt.AddDays(-args.dayOfMonth + 1);
			args.monthStartWeekDay = (int)hcal.GetDayOfWeek(sdt);

			//set hijri current year, month, & day
			args.currentYear = hcal.GetYear(DateTime.Now);
			args.currentMonth = hcal.GetMonth(DateTime.Now);
			args.currentDay = hcal.GetDayOfMonth(DateTime.Now);

			dateObtained(this, args);
		}
Пример #2
0
        public static string GetHijriDate()
        {
            var currentTime = DateTime.Now;

            var hijriCalendar = new HijriCalendar();

            var year    = hijriCalendar.GetYear(currentTime).ToString();
            var month   = hijriCalendar.GetMonth(currentTime).ToString();
            var day     = hijriCalendar.GetDayOfMonth(currentTime).ToString();
            var weekday = hijriCalendar.GetDayOfWeek(currentTime).ToString();

            var nameOfDay   = GetNameOfDay(weekday);
            var nameOfMonth = GetNameOfMonth(month);
            var arabicYear  = ToArabicNumber(year);
            var arabicDay   = ToArabicNumber(day);

            var date = $"{nameOfDay} {arabicDay} {nameOfMonth} {arabicYear}";

            return(date);
        }
Пример #3
0
        private void DateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            dateTimePicker1.CustomFormat = Application.CurrentCulture.DateTimeFormat.LongDatePattern;
            try
            {
                y = persian.GetYear(dateTimePicker1.Value);
                m = persian.GetMonth(dateTimePicker1.Value);
                d = persian.GetDayOfMonth(dateTimePicker1.Value);


                s           = Convert.ToInt32((persian.GetDayOfWeek(dateTimePicker1.Value)));
                label2.Text = string.Format("{3} {2} {1} {0:d4}", y, pm[m - 1], d, wd[s + 1]);

                ya          = arabian.GetYear(dateTimePicker1.Value);
                ma          = arabian.GetMonth(dateTimePicker1.Value);
                da          = arabian.GetDayOfMonth(dateTimePicker1.Value);
                sa          = Convert.ToInt32(arabian.GetDayOfWeek(dateTimePicker1.Value));
                label3.Text = string.Format("{3} {2} {1} {0:d4}", ya, pma[ma - 1], da, wda[sa + 1]);
                DataGridView t = new DataGridView();

                int      iYear     = persian.GetYear(dateTimePicker1.Value);
                int      noflable6 = Array.IndexOf(pm, label6.Text);
                string   dt1       = string.Format("{2:d2}/{1:d2}/{0:d4}", label5.Text, noflable6 + 1, 1);
                DateTime dt2       = DateTime.ParseExact(dt1, "dd/MM/yyyy", CultureInfo.CurrentCulture);
                int      oyear     = persian.GetYear(dt2);
                int      month     = persian.GetMonth(dt2);
                //int s1= Convert.ToInt32((persian.GetDayOfWeek(dt2)));
                int day = 1;

                //dataGridView1.Rows[0].Cells[s1].Value = string.Format("{3} {2} {1} {0:d4}", y, pm[m - 1], d, wd[s1]);
                for (int i = 1; i < 5; i++)
                {
                    //persian.GetDaysInMonth(iYear, noflable6)
                    //Button[] mo = new Button[persian.GetDaysInMonth(iYear, i)];

                    i = dataGridView1.Rows.Add();



                    for (int j = 0; j < 7; j++)
                    {
                        if (day <= persian.GetDaysInMonth(oyear, month))
                        {
                            int      y1 = 0, m1 = 0, d1 = 0, s2, s3;
                            string   dt3 = string.Format("{2:d2}/{1:d2}/{0:d4}", label5.Text, noflable6 + 1, day++);
                            DateTime dt4 = DateTime.ParseExact(dt3, "dd/MM/yyyy", CultureInfo.CurrentCulture);
                            y1 = persian.GetYear(dt4);
                            m1 = persian.GetMonth(dt4);
                            d1 = persian.GetDayOfMonth(dt4);
                            s2 = Convert.ToInt32(persian.GetDayOfWeek(dt4));
                            s3 = Array.IndexOf(wd, wd[s2 + 1]);
                            j  = s3;
                            dataGridView1.Rows[i].Cells[j].Value = $" {pm[m1 - 1]} {y1:d4} {d1}";
                        }


                        //string.Format("{3} {2} {1} {0:d4}", y, pm[m - 1], d, wd[s]);
                    }
                }
            }
            catch (Exception)
            {
                y = persian.GetYear(dateTimePicker1.Value);
                m = persian.GetMonth(dateTimePicker1.Value);
                d = persian.GetDayOfMonth(dateTimePicker1.Value);


                s           = Convert.ToInt32((persian.GetDayOfWeek(dateTimePicker1.Value)));
                label2.Text = string.Format("{3} {2} {1} {0:d4}", y, pm[m - 1], d, wd[s + 1]);

                ya          = arabian.GetYear(dateTimePicker1.Value);
                ma          = arabian.GetMonth(dateTimePicker1.Value);
                da          = arabian.GetDayOfMonth(dateTimePicker1.Value);
                sa          = Convert.ToInt32(arabian.GetDayOfWeek(dateTimePicker1.Value));
                label3.Text = string.Format("{3} {2} {1} {0:d4}", ya, pma[ma - 1], da, wda[sa + 1]);
                DataGridView t = new DataGridView();

                int      iYear     = persian.GetYear(dateTimePicker1.Value);
                int      noflable6 = Array.IndexOf(pm, label6.Text);
                string   dt1       = string.Format("{2:d2}/{1:d2}/{0:d4}", y, m, 1);
                DateTime dt2       = DateTime.ParseExact(dt1, "dd/MM/yyyy", CultureInfo.CurrentCulture);
                int      oyear     = persian.GetYear(dt2);
                int      month     = persian.GetMonth(dt2);
                int      s1        = Convert.ToInt32((persian.GetDayOfWeek(dt2)));
                int      day       = 1;

                //    //dataGridView1.Rows[0].Cells[s1].Value = string.Format("{3} {2} {1} {0:d4}", y, pm[m - 1], d, wd[s1]);
                for (int i = 1; i < 5; i++)
                {
                    //        //persian.GetDaysInMonth(iYear, noflable6)
                    //        //Button[] mo = new Button[persian.GetDaysInMonth(iYear, i)];

                    i = dataGridView1.Rows.Add();



                    for (int j = 0; j < 7; j++)
                    {
                        if (day <= persian.GetDaysInMonth(oyear, month))
                        {
                            int      y1 = 0, m1 = 0, d1 = 0, s2 = 0, s3;
                            string   dt3 = string.Format("{2:d2}/{1:d2}/{0:d4}", y, m, day++);
                            DateTime dt4 = DateTime.ParseExact(dt3, "dd/MM/yyyy", CultureInfo.CurrentCulture);
                            y1 = persian.GetYear(dt4);
                            m1 = persian.GetMonth(dt4);
                            d1 = persian.GetDayOfMonth(dt4);
                            s2 = Convert.ToInt32(persian.GetDayOfWeek(dt4));
                            s3 = Array.IndexOf(wd, wd[s2 + 1]);
                            j  = s3;
                            dataGridView1.Rows[i].Cells[j].Value = $"  {pm[m1 - 1]} {y1:d4} {d1}";
                        }


                        //string.Format("{3} {2} {1} {0:d4}", y, pm[m - 1], d, wd[s]);
                    }
                }
            }

            //dataGridView1.Rows[i].Cells[i].Value=

            //int[] days = new int[persian.GetDaysInMonth(iYear, i)];

            //days[i] = dataGridView1.Rows.Add();
        }
Пример #4
0
 /// <summary>
 /// Gets the day of week.
 /// </summary>
 /// <returns></returns>
 public DayOfWeek GetDayOfWeek()
 {
     return(hc.GetDayOfWeek(dt));
 }