Javascript 如何生成某个公历年的日期到Hijri

Javascript 如何生成某个公历年的日期到Hijri,javascript,c#,kendo-ui,calendar,hijri,Javascript,C#,Kendo Ui,Calendar,Hijri,我想对一年中的几天进行自动调整或生成,从公历到Hijri 我的意思是,您希望选择或编写年份作为示例: 选择2015年: 获取2015年的所有日期,然后将其转换为Hijrim,并提供hijri列表 所以你想回到2个列表1 gregoriad days列表和另一个列表2 hijhri 我想在JavaScript中使用剑道ui框架查看它。剑道ui不支持Hirji日历。剑道ui不支持Hirji日历。剑道ui支持。似乎没有计划添加任何其他内容 您可以使用.NET转换日期 public string C

我想对一年中的几天进行自动调整或生成,从公历到Hijri

我的意思是,您希望选择或编写年份作为示例:

选择2015年:

  • 获取2015年的所有日期,然后将其转换为Hijrim,并提供hijri列表
所以你想回到2个列表1 gregoriad days列表和另一个列表2 hijhri


我想在JavaScript中使用剑道ui框架查看它。

剑道ui不支持Hirji日历。

剑道ui不支持Hirji日历。

剑道ui支持。似乎没有计划添加任何其他内容

您可以使用.NET转换日期

public string ConvertDateCalendar(DateTime DateConv, ECalenderTypes calendar, string DateLangCulture)
{
    System.Globalization.DateTimeFormatInfo DTFormat;
    DateLangCulture = DateLangCulture.ToLower();
    /// We can't have the hijri date writen in English. We will get a runtime error

    if (calendar == ECalenderTypes.Hijri && DateLangCulture.StartsWith("en-"))
    {
        DateLangCulture = "ar-sa";
    }

    /// Set the date time format to the given culture
    DTFormat = new System.Globalization.CultureInfo(DateLangCulture, false).DateTimeFormat;

    /// Set the calendar property of the date time format to the given calendar
    switch (calendar)
    {
        case ECalenderTypes.Hijri:
            DTFormat.Calendar = new System.Globalization.HijriCalendar();
            break;

        case ECalenderTypes.Gregorian:
            DTFormat.Calendar = new System.Globalization.GregorianCalendar();
            break;

        default:
            return "";
    }

    /// We format the date structure to whatever we want 
    DTFormat.ShortDatePattern = "dd/MM/yyyy";
    return (DateConv.Date.ToString("f", DTFormat));
}
然后:

ConvertDateCalendar("01/01/2015", ECalenderTypes.Gregorian, "en-US");
ConvertDateCalendar("01/01/2015", ECalenderTypes.Hijri, "en-US");
JavaScript

function gmod(n,m){
    return ((n%m)+m)%m;
}
function getDate(adjust){
    var today = new Date();
    if(adjust) {
        adjustmili = 1000*60*60*24 * adjust; 
        todaymili = today.getTime() + adjustmili;
        today = new Date(todaymili);
    }
    day = today.getDate();
    month = today.getMonth();
    year = today.getFullYear();
    m = month+1;
    y = year;
    if(m<3) {
        y -= 1;
        m += 12;
    }

    a = Math.floor(y/100.);
    b = 2-a+Math.floor(a/4.);
    if(y<1583) b = 0;
    if(y==1582) {
        if(m>10)  b = -10;
        if(m==10) {
            b = 0;
            if(day>4) b = -10;
        }
    }

    jd = Math.floor(365.25*(y+4716))+Math.floor(30.6001*(m+1))+day+b-1524;

    b = 0;
    if(jd>2299160){
        a = Math.floor((jd-1867216.25)/36524.25);
        b = 1+a-Math.floor(a/4.);
    }
    bb = jd+b+1524;
    cc = Math.floor((bb-122.1)/365.25);
    dd = Math.floor(365.25*cc);
    ee = Math.floor((bb-dd)/30.6001);
    day =(bb-dd)-Math.floor(30.6001*ee);
    month = ee-1;
    if(ee>13) {
        cc += 1;
        month = ee-13;
    }
    year = cc-4716;

    wd = gmod(jd+1,7)+1;

    iyear = 10631./30.;
    epochastro = 1948084;
    epochcivil = 1948085;

    shift1 = 8.01/60.;

    z = jd-epochastro;
    cyc = Math.floor(z/10631.);
    z = z-10631*cyc;
    j = Math.floor((z-shift1)/iyear);
    iy = 30*cyc+j;
    z = z-Math.floor(j*iyear+shift1);
    im = Math.floor((z+28.5001)/29.5);
    if(im==13) im = 12;
    id = z-Math.floor(29.5001*im-29);

    var myRes = new Array(8);

    myRes[0] = day; //calculated day (CE)
    myRes[1] = month-1; //calculated month (CE)
    myRes[2] = year; //calculated year (CE)
    myRes[3] = jd-1; //julian day number
    myRes[4] = wd-1; //weekday number
    myRes[5] = id; //islamic date
    myRes[6] = im-1; //islamic month
    myRes[7] = iy; //islamic year

    return myRes;
}
function writeHijriDate(adjustment) {
    var wdNames = new Array("Ahad","Ithnin","Thulatha","Arbaa","Khams","Jumuah","Sabt");
    var iMonthNames = new Array("Muharram","Safar","Rabi'ul Awwal","Rabi'ul Akhir", "Jumadal Ula","Jumadal Akhira","Rajab","Sha'ban", "Ramadan","Shawwal","Dhul Qa'ada","Dhul Hijja");
    var iDate = getDate(adjustment);
    var outputHijriDate = wdNames[iDate[4]] + ", " + iDate[5] + " " + iMonthNames[iDate[6]] + " " + iDate[7] + " AH";
    return outputHijriDate;
}
剑道用户界面支持。似乎没有计划添加任何其他内容

您可以使用.NET转换日期

public string ConvertDateCalendar(DateTime DateConv, ECalenderTypes calendar, string DateLangCulture)
{
    System.Globalization.DateTimeFormatInfo DTFormat;
    DateLangCulture = DateLangCulture.ToLower();
    /// We can't have the hijri date writen in English. We will get a runtime error

    if (calendar == ECalenderTypes.Hijri && DateLangCulture.StartsWith("en-"))
    {
        DateLangCulture = "ar-sa";
    }

    /// Set the date time format to the given culture
    DTFormat = new System.Globalization.CultureInfo(DateLangCulture, false).DateTimeFormat;

    /// Set the calendar property of the date time format to the given calendar
    switch (calendar)
    {
        case ECalenderTypes.Hijri:
            DTFormat.Calendar = new System.Globalization.HijriCalendar();
            break;

        case ECalenderTypes.Gregorian:
            DTFormat.Calendar = new System.Globalization.GregorianCalendar();
            break;

        default:
            return "";
    }

    /// We format the date structure to whatever we want 
    DTFormat.ShortDatePattern = "dd/MM/yyyy";
    return (DateConv.Date.ToString("f", DTFormat));
}
然后:

ConvertDateCalendar("01/01/2015", ECalenderTypes.Gregorian, "en-US");
ConvertDateCalendar("01/01/2015", ECalenderTypes.Hijri, "en-US");
JavaScript

function gmod(n,m){
    return ((n%m)+m)%m;
}
function getDate(adjust){
    var today = new Date();
    if(adjust) {
        adjustmili = 1000*60*60*24 * adjust; 
        todaymili = today.getTime() + adjustmili;
        today = new Date(todaymili);
    }
    day = today.getDate();
    month = today.getMonth();
    year = today.getFullYear();
    m = month+1;
    y = year;
    if(m<3) {
        y -= 1;
        m += 12;
    }

    a = Math.floor(y/100.);
    b = 2-a+Math.floor(a/4.);
    if(y<1583) b = 0;
    if(y==1582) {
        if(m>10)  b = -10;
        if(m==10) {
            b = 0;
            if(day>4) b = -10;
        }
    }

    jd = Math.floor(365.25*(y+4716))+Math.floor(30.6001*(m+1))+day+b-1524;

    b = 0;
    if(jd>2299160){
        a = Math.floor((jd-1867216.25)/36524.25);
        b = 1+a-Math.floor(a/4.);
    }
    bb = jd+b+1524;
    cc = Math.floor((bb-122.1)/365.25);
    dd = Math.floor(365.25*cc);
    ee = Math.floor((bb-dd)/30.6001);
    day =(bb-dd)-Math.floor(30.6001*ee);
    month = ee-1;
    if(ee>13) {
        cc += 1;
        month = ee-13;
    }
    year = cc-4716;

    wd = gmod(jd+1,7)+1;

    iyear = 10631./30.;
    epochastro = 1948084;
    epochcivil = 1948085;

    shift1 = 8.01/60.;

    z = jd-epochastro;
    cyc = Math.floor(z/10631.);
    z = z-10631*cyc;
    j = Math.floor((z-shift1)/iyear);
    iy = 30*cyc+j;
    z = z-Math.floor(j*iyear+shift1);
    im = Math.floor((z+28.5001)/29.5);
    if(im==13) im = 12;
    id = z-Math.floor(29.5001*im-29);

    var myRes = new Array(8);

    myRes[0] = day; //calculated day (CE)
    myRes[1] = month-1; //calculated month (CE)
    myRes[2] = year; //calculated year (CE)
    myRes[3] = jd-1; //julian day number
    myRes[4] = wd-1; //weekday number
    myRes[5] = id; //islamic date
    myRes[6] = im-1; //islamic month
    myRes[7] = iy; //islamic year

    return myRes;
}
function writeHijriDate(adjustment) {
    var wdNames = new Array("Ahad","Ithnin","Thulatha","Arbaa","Khams","Jumuah","Sabt");
    var iMonthNames = new Array("Muharram","Safar","Rabi'ul Awwal","Rabi'ul Akhir", "Jumadal Ula","Jumadal Akhira","Rajab","Sha'ban", "Ramadan","Shawwal","Dhul Qa'ada","Dhul Hijja");
    var iDate = getDate(adjustment);
    var outputHijriDate = wdNames[iDate[4]] + ", " + iDate[5] + " " + iMonthNames[iDate[6]] + " " + iDate[7] + " AH";
    return outputHijriDate;
}
谢谢大家 我发现有人用Javascript为伊斯兰日历(Hijri)编写了一个简单的实现

它包括从hijri到gregorian的转换,反之亦然ز

谢谢大家 我发现有人用Javascript为伊斯兰日历(Hijri)编写了一个简单的实现


它包括从回历到公历的转换,反之亦然。

回历日期是否总是与公历相同?我的意思是,1770年1月1日和hijri的两个日期在2015年是相同的吗?例如,今天是2015年5月25日,gregorian,那么hijri是6 sha3ban 1436,你有到目前为止你尝试过的不起作用的示例代码吗?没有,我需要数据库:格里高利历的日期与希吉里历的日期是否总是与格里高利历相同?我的意思是,1770年1月1日和hijri的两个日期在2015年是相同的吗?例如,今天是2015年5月25日,gregorian,那么hijri是6 sha3ban 1436,你有到目前为止你尝试过的不起作用的示例代码吗?没有,我有数据库需求:格里高利的日期vs higrican的日期你可以不使用剑道uican你可以不使用剑道uican你可以不使用剑道uican你可以使用angularjsAh,我错过了这一点。:)我还添加了一些JavaScript代码。啊,我错过了。:)我还添加了一些JavaScript代码。