Hijri日历太早了1天。

时间:2013-07-23 06:46:54

标签: c# .net calendar hijri

如何过早地修复Hijri日历?

今天,我的时间= 2013年7月23日星期二 伊斯兰历法时间= 14斋月,1434(根据this

我的日历显示15斋月而不是14.但我不确定这是我的错还是网站的错。任何人都可以确认今天的斋月日期吗?

lblgreg.Text = DateTime.Today.ToString("dd/MM/yyyy");

今天的日期:

DateTime today = DateTime.Today;

将公历转换为Hibri:

CultureInfo Hijri = CultureInfo.CreateSpecificCulture("ar-SA");

        string datetoday_day = today.ToString("dd", Hijri);
        string datetoday_month = today.ToString("MM", Hijri);
        string datetoday_year = today.ToString("yyyy", Hijri);

        int month_check = int.Parse(datetoday_month);

切换语句,表示要切换到text-month的月份值:

switch (month_check) {
            case 01:
                {
                    lbldate.Text  = datetoday_day + " Muharram " + datetoday_year;
                    break;
                }
            case 02:
                {
                    lbldate.Text = datetoday_day + " Safar " + datetoday_year;
                    break;
                }
            case 03:
                {
                    lbldate.Text = datetoday_day + " Rabi Al-Awwal " + datetoday_year;
                    break;
                }
            case 04:
                {
                    lbldate.Text = datetoday_day + " Rabi Al-Akhar " + datetoday_year;
                    break;
                }
            case 05:
                {
                    lbldate.Text = datetoday_day + " Jumada Al-Awwal " + datetoday_year;
                    break;
                }
            case 06:
                {
                    lbldate.Text = datetoday_day + " Jumada Al-Akhirah " + datetoday_year;
                    break;
                }
            case 07:
                {
                    lbldate.Text = datetoday_day + " Rajab " + datetoday_year;
                    break;
                }
            case 08:
                {
                    lbldate.Text = datetoday_day + " Shaban " + datetoday_year;
                    break;
                }
            case 09:
                {
                    lbldate.Text = datetoday_day + " Ramadan " + datetoday_year;
                    break;
                }
            case 10:
                {
                    lbldate.Text = datetoday_day + " Shawwal " + datetoday_year;
                    break;
                }
            case 11:
                {
                    lbldate.Text = datetoday_day + " Dhul-Qadah " + datetoday_year;
                    break;
                }
            case 12:
                {
                    lbldate.Text = datetoday_day + " Dhul-Hijjah " + datetoday_year;
                    break;
                }
        }

3 个答案:

答案 0 :(得分:6)

改为使用UmAlQuraCalendar

var UmAlQuraCalendar = new UmAlQuraCalendar();
CultureInfo Hijri = new CultureInfo("ar-SA")  
{ 
    DateTimeFormat = { Calendar = UmAlQuraCalendar } 
};

答案 1 :(得分:1)

使用HijriAdjustment并将其设置在-2到2之间 像这样

System.Globalization.HijriCalendar hej = new System.Globalization.HijriCalendar();
    hej.HijriAdjustment =-2;

答案 2 :(得分:0)

检查以下代码

using System.Globalization;
//.......
var arDateTimeFormat= new CultureInfo("ar").DateTimeFormat;
arDateTimeFormat.Calendar = new HijriCalendar { HijriAdjustment = -1}; //set HijriAdjustment between -2 to 2
arDateTimeFormat.AbbreviatedMonthNames = new []{"Muharram", "Safar", "Rabi Al-Awwal", "Rabi Al-Akhar", "Jumada Al-Awwal", "Jumada Al-Akhirah", "Rajab", "Shaban", "Ramadan", "Shawwal", "Dhul-Qadah", "Dhul-Hijjah", string.Empty};
lbldate.Text = DateTime.Now.ToString("dd MMM, yyyy", arDateTimeFormat);