private void button1_Click(object sender, EventArgs e) { //تبدیل تاریخ میلادی به شمسی و قمری if (comboBox1.Text != "" & comboBox1.Text != "" & comboBox1.Text != "" & radioButton3.Checked) { date1 = comboBox3.Text + "/" + comboBox2.Text + "/" + comboBox1.Text; DateTime dt = Convert.ToDateTime(date1); label1.Text = pc.GetYear(dt) + "/" + pc.GetMonth(dt) + "/" + pc.GetDayOfMonth(dt); label9.Text = hc.GetYear(dt) + "/" + hc.GetMonth(dt) + "/" + hc.GetDayOfMonth(dt); label10.Text = dt.Year + "/" + dt.Month + "/" + dt.Day; } // //تبدیل تاریخ شمسی به میلادی و قمری if (comboBox1.Text != "" & comboBox1.Text != "" & comboBox1.Text != "" & radioButton1.Checked) { date1 = comboBox3.Text + "/" + comboBox2.Text + "/" + comboBox1.Text; DateTime dt1 = pc.ToDateTime(int.Parse(comboBox3.Text), int.Parse(comboBox2.Text), int.Parse(comboBox1.Text), 0, 0, 0, 0); label1.Text = date1; label9.Text = hc.GetYear(dt1) + "/" + hc.GetMonth(dt1) + "/" + hc.GetDayOfMonth(dt1); label10.Text = dt1.Year + "/" + dt1.Month + "/" + dt1.Day; } // //تبدیل تاریخ قمری به شمسی و میلادی if (comboBox1.Text != "" & comboBox1.Text != "" & comboBox1.Text != "" & radioButton2.Checked) { date1 = comboBox3.Text + "/" + comboBox2.Text + "/" + comboBox1.Text; DateTime dt2 = hc.ToDateTime(int.Parse(comboBox3.Text), int.Parse(comboBox2.Text), int.Parse(comboBox1.Text), 0, 0, 0, 0); label1.Text = pc.GetYear(dt2) + "/" + pc.GetMonth(dt2) + "/" + pc.GetDayOfMonth(dt2); label9.Text = date1; label10.Text = dt2.Year + "/" + dt2.Month + "/" + dt2.Day; } }
public static void Main() { // Creates and initializes a HijriCalendar. HijriCalendar myCal = new HijriCalendar(); // Creates a DateTime and initializes it to the second day of the first month of the year 1422. DateTime myDT = new DateTime(1422, 1, 2, myCal); // Displays the current values of the DateTime. Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment); Console.WriteLine(" Year is {0}.", myCal.GetYear(myDT)); Console.WriteLine(" Month is {0}.", myCal.GetMonth(myDT)); Console.WriteLine(" Day is {0}.", myCal.GetDayOfMonth(myDT)); // Sets the HijriAdjustment property to 2. myCal.HijriAdjustment = 2; Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment); Console.WriteLine(" Year is {0}.", myCal.GetYear(myDT)); Console.WriteLine(" Month is {0}.", myCal.GetMonth(myDT)); Console.WriteLine(" Day is {0}.", myCal.GetDayOfMonth(myDT)); // Sets the HijriAdjustment property to -2. myCal.HijriAdjustment = -2; Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment); Console.WriteLine(" Year is {0}.", myCal.GetYear(myDT)); Console.WriteLine(" Month is {0}.", myCal.GetMonth(myDT)); Console.WriteLine(" Day is {0}.", myCal.GetDayOfMonth(myDT)); }
public static LuniarDate Now() { LuniarDate hd = new LuniarDate(); DateTime miladi = DateTime.Now; hd.Day = HCal.GetDayOfMonth(miladi); hd.Month = HCal.GetMonth(miladi); hd.Year = HCal.GetYear(miladi); return(hd); }
public static string GregorianTo(string xCalendarType, string xDateTime) { string result = null; if (string.IsNullOrWhiteSpace(xDateTime)) { return(null); } var _xDateTime = Convert.ToDateTime(xDateTime); var _xTime = xDateTime.Split(' '); switch (xCalendarType.ToLower()) { case "hijrishamsi": var pc = new PersianCalendar(); result = pc.GetYear(_xDateTime).ToString("0000") + "/" + pc.GetMonth(_xDateTime).ToString("00") + "/" + pc.GetDayOfMonth(_xDateTime).ToString("00") + (_xTime.Length == 2 ? " " + _xTime[1] : ""); break; case "hijrighamari": var hc = new HijriCalendar(); result = hc.GetYear(_xDateTime).ToString("0000") + "/" + hc.GetMonth(_xDateTime).ToString("00") + "/" + hc.GetDayOfMonth(_xDateTime).ToString("00") + (_xTime.Length == 2 ? " " + _xTime[1] : ""); break; default: return(null); } return(result); }
/// <summary> /// متد تبديل تاريخ ميلادي به قمري /// </summary> public void MiladiToGhamari() { HijriCalendar hc = new HijriCalendar(); DateTime dt = new DateTime(year: Year, month: Month, day: Day); string result = $"Miladi To Ghamari:{ hc.GetYear(dt).ToString("0000/") } { hc.GetMonth(dt).ToString("00/") } { hc.GetDayOfMonth(dt).ToString("00") }"; System.Console.Write(result); }
public static string Hijri(DateTime firstDayOfMonth, DateTime lastDayOfMonth) { var hijriCal = new HijriCalendar(); var firstDayOfMonthHijri = hijriCal.GetMonth(firstDayOfMonth); var lastDayOfMonthHijri = hijriCal.GetMonth(lastDayOfMonth); return(firstDayOfMonthHijri.Equals(lastDayOfMonthHijri) ? $"{MonthsName.Hijri(firstDayOfMonthHijri)} {ArabicDigits.Convert(hijriCal.GetYear(firstDayOfMonth).ToString())}" : $"{MonthsName.Hijri(firstDayOfMonthHijri)} — {MonthsName.Hijri(lastDayOfMonthHijri)} {ArabicDigits.Convert(hijriCal.GetYear(firstDayOfMonth).ToString())}"); }
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); }
private void CommonConstructor(DateTime dateTime) { this.dateTime = dateTime; this.Year = persianCalendar.GetYear(dateTime); this.Month = persianCalendar.GetMonth(dateTime); this.Day = persianCalendar.GetDayOfMonth(dateTime); this.Hour = persianCalendar.GetHour(dateTime); this.Minute = persianCalendar.GetMinute(dateTime); this.Second = persianCalendar.GetSecond(dateTime); this.Millisecond = Convert.ToInt32(persianCalendar.GetMilliseconds(dateTime)); this.HijriDate = new HijriDate(); this.HijriDate.Year = hijri.GetYear(this.dateTime); this.HijriDate.Month = hijri.GetMonth(this.dateTime); this.HijriDate.Day = hijri.GetDayOfMonth(this.dateTime); this.DateMetaDatas = HoliDaysData.Instance.GetMetaDataByDateTime(this.dateTime); this.IsHoliDay = this.dateTime.DayOfWeek == System.DayOfWeek.Friday; foreach (var item in DateMetaDatas) { this.IsHoliDay = this.IsHoliDay || item.IsHoliDay || this.dateTime.DayOfWeek == System.DayOfWeek.Friday; } }
public static string ToHijri(this DateTime?value) { if (value.HasValue) { var dt = (DateTime)value; var hc = new HijriCalendar(); return(string.Format("{0}/{1}/{2}", hc.GetYear(dt), hc.GetMonth(dt) < 10 ? "0" + hc.GetMonth(dt).ToString() : hc.GetMonth(dt).ToString(), hc.GetDayOfMonth(dt) < 10 ? "0" + hc.GetDayOfMonth(dt).ToString() : hc.GetDayOfMonth(dt).ToString())); } else { return("..."); } }
public static string ToHijriWithTime(this DateTime?value) { if (value.HasValue) { var dt = (DateTime)value; var hc = new HijriCalendar(); return(string.Format("{0}/{1}/{2} - {3}:{4}", hc.GetYear(dt), hc.GetMonth(dt), hc.GetDayOfMonth(dt), dt.Hour < 10 ? string.Format("0{0}", dt.Hour) : dt.Hour.ToString(), dt.Minute < 10 ? string.Format("0{0}", dt.Minute) : dt.Minute.ToString())); } else { return("..."); } }
public static string Convert_Milady_To_Hijry(string date) { try { DateTime time = DateTime.Parse(date); hijri.HijriAdjustment = -1; string[] strArray = new string[5]; int index = 0; strArray[index] = hijri.GetYear(time).ToString().PadLeft(4, '0'); int num2 = 1; strArray[num2] = "/"; int num3 = 2; strArray[num3] = hijri.GetMonth(time).ToString().PadLeft(2, '0'); int num4 = 3; strArray[num4] = "/"; int num5 = 4; strArray[num5] = hijri.GetDayOfMonth(time).ToString().PadLeft(2, '0'); return(string.Concat(strArray)); } catch { } return(""); }
static void Main(string[] args) { MyApp = new Excel.Application(); MyApp.Visible = true; //if (!File.Exists("CalendarBook.xlsx")) // MyApp.Workbooks.Open( MyBook = MyApp.Workbooks.Add(); MySheet = (Excel.Worksheet)MyBook.ActiveSheet; // Explicit cast is not required here var lastRow = MySheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row; int year = 1397, month = 1, day = 1; DateTime startDate = Tools.shamsiStringToMiladi(year, month, day); for (int i = 0; i < 366; i++) { DateTime newDate = startDate.AddDays(i); PersianCalendar perCal = new PersianCalendar(); HijriCalendar hijriCal = new HijriCalendar(); int miladiYear = newDate.Year; int miladiMonth = newDate.Month; int miladiDay = newDate.Day; string miladiMonthName = newDate.ToString("MMMM", CultureInfo.CreateSpecificCulture("en")); int shamsiYear = perCal.GetYear(newDate); int shamsiMonth = perCal.GetMonth(newDate); int shamsiDay = perCal.GetDayOfMonth(newDate); string shmasiMonthName = newDate.ToString("MMMM", CultureInfo.CreateSpecificCulture("fa")); string shmasiWeekDayName = newDate.ToString("ddd", CultureInfo.CreateSpecificCulture("fa")); int HijriYear = hijriCal.GetYear(newDate); int HijriMonth = hijriCal.GetMonth(newDate); int HijriDay = hijriCal.GetDayOfMonth(newDate); string HijriMonthName = newDate.ToString("MMMM", CultureInfo.CreateSpecificCulture("ar")); lastRow += 1; MySheet.Cells[lastRow, 1] = shamsiYear; MySheet.Cells[lastRow, 2] = shamsiMonth; MySheet.Cells[lastRow, 3] = shamsiDay; MySheet.Cells[lastRow, 4] = shmasiMonthName; MySheet.Cells[lastRow, 5] = shmasiWeekDayName; MySheet.Cells[lastRow, 6] = HijriYear; MySheet.Cells[lastRow, 7] = HijriMonth; MySheet.Cells[lastRow, 8] = HijriDay; MySheet.Cells[lastRow, 9] = HijriMonthName; MySheet.Cells[lastRow, 10] = miladiYear; MySheet.Cells[lastRow, 11] = miladiMonth; MySheet.Cells[lastRow, 12] = miladiDay; MySheet.Cells[lastRow, 13] = miladiMonthName; } MyBook.SaveAs("CalndarTable"); }
public static string ConvertToArabic(DateTime _DateTime, string _Format = "{Year}/{Month}/{Day}") { try { HijriCalendar _HijriCalendar = new HijriCalendar(); string _strHijriDate = null; _strHijriDate = _Format.ToLower().Replace("{Year}".ToLower(), _HijriCalendar.GetYear(_DateTime).ToString("0000")) .Replace("{Month}".ToLower(), _HijriCalendar.GetMonth(_DateTime).ToString("00")) .Replace("{Day}".ToLower(), _HijriCalendar.GetDayOfMonth(_DateTime).ToString("00")); return(_strHijriDate); } catch (Exception ex) { return(""); } }
/// <summary> /// تاریخ شروع ماه رمضان /// <para /> /// چون ممکن است در یک سال شمسی دو شروع ماه رمضان داشته باشیم /// <para /> /// مقدار بازگشتی آرایه است که حداکثر دو آیتم دارد /// </summary> public PersianDateTime[] GetStartDayOfRamadan(int hijriAdjustment) { var result = new List<PersianDateTime>(); var hijriCalendar = new HijriCalendar { HijriAdjustment = hijriAdjustment }; var currentHijriYear = hijriCalendar.GetYear(_dateTime); var startDayOfRamadan1 = new PersianDateTime(hijriCalendar.ToDateTime(currentHijriYear, 9, 1, 0, 0, 0, 0)); result.Add(startDayOfRamadan1); var startDayOfRamadan2 = new PersianDateTime(hijriCalendar.ToDateTime(++currentHijriYear, 9, 1, 0, 0, 0, 0)); if (startDayOfRamadan1.Year == startDayOfRamadan2.Year) result.Add(startDayOfRamadan2); return result.ToArray(); }
public string MiladiTohejri(DateTime Hdate) { string Result = hc.GetYear(Hdate).ToString(); string Month = Convert.ToString(hc.GetMonth(Hdate)); string day = Convert.ToString(hc.GetDayOfMonth(Hdate)); if (Month.Length == 1) { Month = "0" + Month; } if (day.Length == 1) { day = "0" + day; } Result += "/" + Month + "/" + day; return(Result); }
/// <summary> /// Converts Gregorian date to Hijri(Arabic) /// </summary> public static string GregorianToHijri(this DateTime date, IncludeTime includeTime) { if (date < GC.MinSupportedDateTime) { throw new ArgumentOutOfRangeException("date", "input date time object is invalid" + $", minimum gregorian calendar date is: '{date:D}'."); } if (date > GC.MaxSupportedDateTime) { throw new ArgumentOutOfRangeException("date", "input date time object is invalid" + $", maximum gregorian calendar date is: '{date:D}'."); } string result = string.Format("{0}/{1}/{2}" , HC.GetYear(date), HC.GetMonth(date), HC.GetDayOfMonth(date)); switch (includeTime) { case IncludeTime.No: break; case IncludeTime.JustHour: result = string.Concat(result, string.Format(" - {0}:00" , PadWithLeadingZeros(PC.GetHour(date)))); break; case IncludeTime.HourAndMinute: result = string.Concat(result, string.Format(" - {0}:{1}" , PadWithLeadingZeros(PC.GetHour(date)) , PadWithLeadingZeros(PC.GetMinute(date)))); break; case IncludeTime.Complete: result = string.Concat(result, string.Format(" - {0}:{1}:{2}" , PadWithLeadingZeros(PC.GetHour(date)) , PadWithLeadingZeros(PC.GetMinute(date)) , PadWithLeadingZeros(PC.GetSecond(date)))); break; default: break; } return(result); }
public DropDownPage() { InitializeComponent(); /* * Time Display * Device.StartTimer(TimeSpan.FromSeconds(1), () => { * * Device.BeginInvokeOnMainThread(() => myDate.Text = DateTime.Now.ToString()); * return true; * }); */ HijriCalendar islamicCalendar = new HijriCalendar(); islamicCalendar.HijriAdjustment = -1; myIslamicDate.Text = islamicMonth(islamicCalendar.GetMonth(DateTime.Now)) + " " + islamicCalendar.GetDayOfMonth(DateTime.Now).ToString() + ", " + islamicCalendar.GetYear(DateTime.Now).ToString() + "AH"; }
[Test, Timeout(180000)] // Can take a long time under NCrunch. public void BclThroughHistory() { Calendar hijri = new HijriCalendar(); DateTime bclDirect = new DateTime(1, 1, 1, 0, 0, 0, 0, hijri, DateTimeKind.Unspecified); CalendarSystem islamicCalendar = CalendarSystem.GetIslamicCalendar(IslamicLeapYearPattern.Base16, IslamicEpoch.Astronomical); CalendarSystem julianCalendar = CalendarSystem.GetJulianCalendar(4); LocalDate julianIslamicEpoch = new LocalDate(622, 7, 15, julianCalendar); LocalDate islamicDate = julianIslamicEpoch.WithCalendar(islamicCalendar); for (int i = 0; i < 9000 * 365; i++) { Assert.AreEqual(bclDirect, islamicDate.AtMidnight().ToDateTimeUnspecified()); Assert.AreEqual(hijri.GetYear(bclDirect), islamicDate.Year, i.ToString()); Assert.AreEqual(hijri.GetMonth(bclDirect), islamicDate.Month); Assert.AreEqual(hijri.GetDayOfMonth(bclDirect), islamicDate.Day); bclDirect = hijri.AddDays(bclDirect, 1); islamicDate = islamicDate.PlusDays(1); } }
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); }
// --------------------------------------------------------------------------------[ 1423/6/2 ]-------------------------------------- // #region ToHijri public static string ToHijri(this DateTime value) { var hc = new HijriCalendar(); return(string.Format("{0}/{1}/{2}", hc.GetYear(value), hc.GetMonth(value) < 10 ? "0" + hc.GetMonth(value).ToString() : hc.GetMonth(value).ToString(), hc.GetDayOfMonth(value) < 10 ? "0" + hc.GetDayOfMonth(value).ToString() : hc.GetDayOfMonth(value).ToString())); }
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(); }
private async Task <string> GetCurrentHijriYear() { HijriCalendar hijri = new HijriCalendar(); return(hijri.GetYear(DateTime.Now).ToString()); }
public static void Main() { // Create an instance of the calendar. HijriCalendar myCal = new HijriCalendar(); Console.WriteLine(myCal.ToString()); // Create an instance of the GregorianCalendar. GregorianCalendar myGre = new GregorianCalendar(); // Display the MinSupportedDateTime and its equivalent in the GregorianCalendar. DateTime myMin = myCal.MinSupportedDateTime; Console.Write("MinSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal.GetMonth(myMin), myCal.GetDayOfMonth(myMin), myCal.GetYear(myMin)); Console.WriteLine(" (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre.GetMonth(myMin), myGre.GetDayOfMonth(myMin), myGre.GetYear(myMin)); // Display the MaxSupportedDateTime and its equivalent in the GregorianCalendar. DateTime myMax = myCal.MaxSupportedDateTime; Console.Write("MaxSupportedDateTime: {0:D2}/{1:D2}/{2:D4}", myCal.GetMonth(myMax), myCal.GetDayOfMonth(myMax), myCal.GetYear(myMax)); Console.WriteLine(" (in Gregorian, {0:D2}/{1:D2}/{2:D4})", myGre.GetMonth(myMax), myGre.GetDayOfMonth(myMax), myGre.GetYear(myMax)); }
public static string GetHijriDate(this DateTime theDate) { return($"{hijri.GetYear(theDate).ToString("00")}/{hijri.GetMonth(theDate).ToString("00")}/{hijri.GetDayOfMonth(theDate).ToString("00")}"); }
public static int GetHijriYear(this DateTime date) => _hijriCalendar.GetYear(date);
/// <summary> /// انواع خروجی های فارسی /// </summary> /// <returns></returns> private string hijricalendar() { return(hijrical.GetDayOfMonth(mydate).ToString() + " / " + hijrical.GetMonth(mydate).ToString() + " / " + hijrical.GetYear(mydate).ToString()); }
// -------------------------------------------------------------------------------[ 1423/6/2 - 13:02 ]------------------------------- // #region ToHijriWithTime public static string ToHijriWithTime(this DateTime value) { var hc = new HijriCalendar(); return(string.Format("{0}/{1}/{2} - {3}:{4}", hc.GetYear(value), hc.GetMonth(value), hc.GetDayOfMonth(value), value.Hour < 10 ? string.Format("0{0}", value.Hour) : value.Hour.ToString(), value.Minute < 10 ? string.Format("0{0}", value.Minute) : value.Minute.ToString())); }
private void LoadFormSettings() { loadAllData(); strCurrentDate = DateTime.Today.ToString("dd/MM/yyyy"); pnlJadwal.Width = Screen.PrimaryScreen.Bounds.Width; var intWidth = pnlJadwal.Width / 6; var xLoc = intWidth; var xSpace = 3; pnlImsak.Height = pnlJadwal.Height; pnlImsak.Width = intWidth; pnlSubuh.Height = pnlJadwal.Height; pnlSubuh.Width = intWidth; pnlDzuhur.Height = pnlJadwal.Height; pnlDzuhur.Width = intWidth; pnlAshar.Height = pnlJadwal.Height; pnlAshar.Width = intWidth; pnlMagrib.Height = pnlJadwal.Height; pnlMagrib.Width = intWidth; pnlIsya.Height = pnlJadwal.Height; pnlIsya.Width = intWidth; pnlSubuh.Location = new Point(intWidth + xSpace + 2, 0); intWidth += xLoc + xSpace; pnlDzuhur.Location = new Point(intWidth + xSpace + 2, 0); intWidth += xLoc + xSpace;; pnlAshar.Location = new Point(intWidth + xSpace + 2, 0); intWidth += xLoc + xSpace;; pnlMagrib.Location = new Point(intWidth + xSpace + 2, 0); intWidth += xLoc + xSpace;; pnlIsya.Location = new Point(intWidth + xSpace + 2, 0); pnlIsya.Width = Screen.PrimaryScreen.Bounds.Width - (intWidth + xSpace + 5); lblImsyak.Left = (pnlImsak.Width - lblImsyak.Size.Width) / 2; lblSubuh.Left = (pnlSubuh.Width - lblSubuh.Size.Width) / 2; lblDzuhur.Left = (pnlDzuhur.Width - lblDzuhur.Size.Width) / 2; lblAshar.Left = (pnlAshar.Width - lblAshar.Size.Width) / 2; lblMagrib.Left = (pnlMagrib.Width - lblMagrib.Size.Width) / 2; lblIsya.Left = (pnlIsya.Width - lblIsya.Size.Width) / 2; lblImsakTime.Left = (pnlImsak.Width - lblImsakTime.Size.Width) / 2; lblSubuhTime.Left = (pnlSubuh.Width - lblSubuhTime.Size.Width) / 2; lblZuhurTime.Left = (pnlSubuh.Width - lblZuhurTime.Size.Width) / 2; lblAshartime.Left = (pnlAshar.Width - lblAshartime.Size.Width) / 2; lblMagribtime.Left = (pnlMagrib.Width - lblMagribtime.Size.Width) / 2; lblIsyaTime.Left = (pnlIsya.Width - lblIsyaTime.Size.Width) / 2; lblJam.Location = new Point(pnlJadwal.Width - 210, 9); lblTanggalArab.Location = new Point(pnlJadwal.Width - 230, 60); lblalamat.Width = pnlJadwal.Width; lblNamaMasjid.Left = (Screen.PrimaryScreen.Bounds.Width - lblNamaMasjid.Size.Width) / 2; lblalamat.Left = (Screen.PrimaryScreen.Bounds.Width - lblalamat.Size.Width) / 2; pnlCountDown.Location = new Point(0, Screen.PrimaryScreen.Bounds.Height - 250); lblHari.Text = DateTime.Now.ToString("dddd"); lblTanggal.Text = DateTime.Now.ToString("dd MMMM yyyy"); HijriCalendar myCal = new HijriCalendar(); lblTanggalArab.Text = $"{myCal.GetDayOfMonth(DateTime.Today)} {ConvertIntToArabMonthName(myCal.GetMonth(DateTime.Today))} {myCal.GetYear(DateTime.Today)}"; tmrImage.Enabled = true; tmrJam.Enabled = true; _xpos = lblRunningText.Location.X; _ypos = lblRunningText.Location.Y; }
/// <summary> /// Gets the year in Hijri Ghamari calendar. /// </summary> /// <returns></returns> public int GetYear() { return(hc.GetYear(dt)); }