我想在asp.net中创建文本框以从用户获取波斯日期并转换为格鲁吉亚日期以与我的SQL数据库中的日期列日期进行比较,任何人都可以帮助我吗?
答案 0 :(得分:0)
您可以使用此javaScript代码:
function jalali_to_gregorian(jy,jm,jd){
if(jy > 979){
gy=1600;
jy-=979;
}else{
gy=621;
}
days=(365*jy) +((parseInt(jy/33))*8) +(parseInt(((jy%33)+3)/4)) +78 +jd +((jm<7)?(jm-1)*31:((jm-7)*30)+186);
gy+=400*(parseInt(days/146097));
days%=146097;
if(days > 36524){
gy+=100*(parseInt(--days/36524));
days%=36524;
if(days >= 365)days++;
}
gy+=4*(parseInt(days/1461));
days%=1461;
if(days > 365){
gy+=parseInt((days-1)/365);
days=(days-1)%365;
}
gd=days+1;
sal_a=[0,31,((gy%4==0 && gy%100!=0) || (gy%400==0))?29:28,31,30,31,30,31,31,30,31,30,31];
for(gm=0;gm<13;gm++){
v=sal_a[gm];
if(gd <= v)break;
gd-=v;
}
return [gy,gm,gd];
}
或使用此VisualBasic代码:
Function jalali_to_gregorian(ByVal jy As Long, ByVal jm As Long, ByVal jd As Long)
Dim sal_a(12), out(2), gy, gm, gd, days, jm2, gm2, i As Long
If jy > 979 Then
gy = 1600
jy = jy - 979
Else
gy = 621
End If
jm2 = IIf(jm < 7, (jm - 1) * 31, ((jm - 7) * 30) + 186)
days = (365 * jy) + ((jy \ 33) * 8) + (((jy Mod 33) + 3) \ 4) + 78 + jd + jm2
gy = gy + (400 * (days \ 146097))
days = days Mod 146097
If days > 36524 Then
days = days - 1
gy = gy + (100 * (days \ 36524))
days = days Mod 36524
If days >= 365 Then
days = days + 1
End If
End If
gy = gy + (4 * (days \ 1461))
days = days Mod 1461
If days > 365 Then
gy = gy + ((days - 1) \ 365)
days = (days - 1) Mod 365
End If