<%
function date_shamsi(dates,short)
D = Array (20, 19, 20, 20, 21, 21, 22, 22, 22, 22, 21, 21)
P = Array (11, 12, 10, 12, 11, 11, 10, 10, 10, 9, 10, 10)
W = Array ("يکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه")
Mon = Array ("فروردين", "ارديبهشت", "خرداد", "تير", "مرداد", "شهريور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند")
Dm = day(dates)
Mm = month(dates)
Ym = year(dates)
U = 0
Rp = 0
if (Ym mod 4)=0 then U=1
if (Ym mod 100)=0 and (Ym mod 400)<>0 then U=0
Ys = Ym - 622
X = Ys - 22
X = X mod 33
if (((X mod 4)=0) AND X <> 32) then Rp = 1
I = (not (Rp-2)) + (not (U - 2)) * 2
X = 0
if(I = 0 AND Mm = 3) then X = 1
if(I = 0) then I = 3
Ms = (9 + Mm) mod 13
if(Ms < 10) then Ms = Ms + 1
D1 = D(Mm - 1)
if(I = 1 AND Mm > 2) then D1 = D1 - 1
if (I = 2 AND Mm < 3) then D1 = D1 - 1
P1 = P(Mm - 1)
if(I = 1 AND Mm > 2) then P1 = P1 + 1
if(I = 2 AND Mm < 4) then P1 = P1 + 1
if(Dm > 0 AND Dm <= D1) then
Ds = P1 + Dm + X - 1
X = 1
else
Ds = Dm - D1
Ms = Ms + 1
if(Ms = 13) then Ms = 1
X = 2
end if
if((Mm = 3 AND X = 2) OR Mm > 3) then Ys = Ys + 1
if(Ms<10) then Ms="0"&Ms
if(Ds<10) then Ds="0"&Ds
if short then
date_shamsi=Ys&"/"&Ms&"/"&Ds
else
date_shamsi=w(weekday(dates)-1)&" "&Ds&" "&mon(Ms-1)&" "&Ys
end if
end function
%>