4

如何修复回历日历提前 1 天?

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

我的日历显示 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);

将月份值转换为文本月份的 Switch 语句:

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;
                }
        }
4

3 回答 3

6

Use UmAlQuraCalendar instead.

var UmAlQuraCalendar = new UmAlQuraCalendar();
CultureInfo Hijri = new CultureInfo("ar-SA")  
{ 
    DateTimeFormat = { Calendar = UmAlQuraCalendar } 
};
于 2013-08-13T16:16:28.043 回答
2

使用 HijriAdjustment 并将其设置在 -2 到 2 之间,如下所示

System.Globalization.HijriCalendar hej = new System.Globalization.HijriCalendar();
    hej.HijriAdjustment =-2;
于 2014-10-12T06:31:25.917 回答
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);
于 2018-01-29T23:10:59.610 回答