<%
Function persian_weekday(iYear, iMonth, iDay)
jdn = persian_jdn(iYear, iMonth, iDay)
jdn = ((jdn + 1) MOD 7)
persian_weekday = jdn + 2
if persian_weekday = 8 then
persian_weekday = 1
end if
End Function
Sub jdn_persian(jdn , iYear, iMonth, iDay)
depoch = jdn - persian_jdn(475, 1, 1)
cycle = Fix(depoch / 1029983)
cyear = depoch Mod 1029983
If cyear = 1029982 Then
ycycle = 2820
Else
aux1 = Fix(cyear / 366)
aux2 = cyear Mod 366
ycycle = Int(((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1
End If
iYear = ycycle + (2820 * cycle) + 474
If iYear <= 0 Then
iYear = iYear - 1
End If
yday = (jdn - persian_jdn(iYear, 1, 1)) + 1
If yday <= 186 Then
iMonth = Ceil(yday / 31)
Else
iMonth = Ceil((yday - 6) / 30)
End If
iDay = (jdn - persian_jdn(iYear, iMonth, 1)) + 1
End Sub
Private Function Ceil(number)
Ceil = -Sgn(number) * Int(-Abs(number))
End Function
Function persian_jdn(iYear, iMonth, iDay)
If iYear >= 0 Then
epbase = iYear - 474
Else
epbase = iYear - 473
End If
epyear = 474 + (epbase Mod 2820)
If iMonth <= 7 Then
mdays = (CLng(iMonth) - 1) * 31
Else
mdays = (CLng(iMonth) - 1) * 30 + 6
End If
persian_jdn = CLng(iDay) + mdays + Fix(((epyear * 682) - 110) / 2816) + (epyear - 1) * 365 + Fix(epbase / 2820) * 1029983 + (1948321 - 1)
End Function
Function civil_jdn(iYear, iMonth, iDay)
If ((iYear > 1582) Or ((iYear = 1582) And (iMonth > 10)) Or ((iYear = 1582) And (iMonth = 10) And (iDay > 14))) Then
lYear = CLng(iYear)
lMonth = CLng(iMonth)
lDay = CLng(iDay)
civil_jdn = ((1461 * (lYear + 4800 + ((lMonth - 14) \ 12))) \ 4) + ((367 * (lMonth - 2 - 12 * (((lMonth - 14) \ 12)))) \ 12) - ((3 * (((lYear + 4900 + ((lMonth - 14) \ 12)) \ 100))) \ 4) + lDay - 32075
Else
civil_jdn = julian_jdn(iYear, iMonth, iDay)
End If
End Function
Function julian_jdn(iYear, iMonth, iDay)
lYear = CLng(iYear)
lMonth = CLng(iMonth)
lDay = CLng(iDay)
julian_jdn = 367 * lYear - ((7 * (lYear + 5001 + ((lMonth - 9) \ 7))) \ 4) + ((275 * lMonth) \ 9) + lDay + 1729777
End Function
Sub jdn_civil(jdn, iyear, imonth, iday)
If (jdn > 2299160) Then
l = jdn + 68569
n = ((4 * l) \ 146097)
l = l - ((146097 * n + 3) \ 4)
i = ((4000 * (l + 1)) \ 1461001)
l = l - ((1461 * i) \ 4) + 31
j = ((80 * l) \ 2447)
iday = l - ((2447 * j) \ 80)
l = (j \ 11)
imonth = j + 2 - 12 * l
iyear = 100 * (n - 49) + i + l
Else
Call jdn_julian(jdn, iyear, imonth, iday)
End If
End Sub
Sub jdn_julian(jdn, iYear, iMonth, iDay)
j = jdn + 1402
k = ((j - 1) \ 1461)
l = j - 1461 * k
n = ((l - 1) \ 365) - (l \ 1461)
i = l - 365 * n + 30
j = ((80 * i) \ 2447)
iDay = i - ((2447 * j) \ 80)
i = (j \ 11)
iMonth = j + 2 - 12 * i
iYear = 4 * k + n + i - 4716
End Sub
Sub civil_persian(iYear, iMonth, iDay)
Call jdn_persian(civil_jdn(iYear, iMonth, iDay), iYear, iMonth, iDay)
End Sub
Sub persian_civil(iYear, iMonth, iDay)
Call jdn_civil(persian_jdn(iYear, iMonth, iDay), iYear, iMonth, iDay)
End Sub
Function persian_WeekName(iWeek)
Select Case iWeek
Case 1 persian_WeekName = "شنبه"
Case 2 persian_WeekName = "يكشنبه"
Case 3 persian_WeekName = "دوشنبه"
Case 4 persian_WeekName = "سه شنبه"
Case 5 persian_WeekName = "چهارشنبه"
Case 6 persian_WeekName = "پنجشنبه"
Case 7 persian_WeekName = "جمعه"
Case Else persian_WeekName = "Error"
End Select
End Function
Function persian_MonthName(iMonth)
Select Case iMonth
Case 1
persian_MonthName = "فروردين"
Case 2
persian_MonthName = "اردی&nbsp;بهشت"
Case 3
persian_MonthName = "خرداد"
Case 4
persian_MonthName = "تير"
Case 5
persian_MonthName = "مرداد"
Case 6
persian_MonthName = "شهريور"
Case 7
persian_MonthName = "مهر"
Case 8
persian_MonthName = "آبان"
Case 9
persian_MonthName = "آذر"
Case 10
persian_MonthName = "دى"
Case 11
persian_MonthName = "بهمن"
Case 12
persian_MonthName = "اسفند"
Case Else
persian_MonthName = "Error"
End Select
End Function
'***************************************************************************************************
datetime = date + timeserial (hour(now), minute(now) , second(now))
nDay = day(datetime ) 'day in persian time !
nMonth = month(datetime ) 'mounth in persian time
nYear = year(datetime ) 'year in persian time !
call civil_persian(nYear, nMonth, nDay)
nWeekday = persian_Weekname(persian_weekday(nYear, nMonth, nDay))
nMonth = persian_Monthname(nMonth)
Today = nWeekday & " " & nDay & " " & nMonth & " " & nYear & " "' & " ساعت : " & hour(datetime) & ":" & minute(datetime)' & " - " & WeekDayName(WeekDay(datetime), TRUE) & " " & MonthName(Month(datetime), TRUE) & " " & Day(datetime) & " " &Year(datetime) & "&nbsp;"
response.Write(today)
%>