S
Steve
Microsoft has introduced a Persian Calendar Class in ASP.net 2.0
http://msdn2.microsoft.com/en-us/library/system.globalization.persiancalendar.aspx
I have looked at the methods and the only way I have managed to convert
a date from Persian to Gregorian or vice versa is to use the getyear,
getmonth and getdayofmonth methods. ie. my code looks something like
this:
'Get gregorian date and return persian date
Function PDate(ByVal g As Date) As Date
Dim pc As New System.Globalization.PersianCalendar
Dim persian As Date
Dim year As Integer = pc.GetYear(g)
Dim month As Integer = pc.GetMonth(g)
Dim day As Integer = pc.GetDayOfMonth(g)
persian = day & "/" & month & "/" & year
persian = CType(persian, Date)
Return persian
End Function
However, I run into a problem for Persian dates such as 31/06/1385
(equivalent to 22/09/2006), where 31 days exist in the 6th month of the
Persian month but not in the Gregorian month. The code refuses to
accept this as a valid date format.
So, I am sure I must be using the wrong approach with this class, i.e.
the wrong methodology for conversions between the Persian and Gregorian
calendar. Could somebody possibly have a look at the class and tell me
what I should be doing instead?
Kind regards,
Steve.
http://msdn2.microsoft.com/en-us/library/system.globalization.persiancalendar.aspx
I have looked at the methods and the only way I have managed to convert
a date from Persian to Gregorian or vice versa is to use the getyear,
getmonth and getdayofmonth methods. ie. my code looks something like
this:
'Get gregorian date and return persian date
Function PDate(ByVal g As Date) As Date
Dim pc As New System.Globalization.PersianCalendar
Dim persian As Date
Dim year As Integer = pc.GetYear(g)
Dim month As Integer = pc.GetMonth(g)
Dim day As Integer = pc.GetDayOfMonth(g)
persian = day & "/" & month & "/" & year
persian = CType(persian, Date)
Return persian
End Function
However, I run into a problem for Persian dates such as 31/06/1385
(equivalent to 22/09/2006), where 31 days exist in the 6th month of the
Persian month but not in the Gregorian month. The code refuses to
accept this as a valid date format.
So, I am sure I must be using the wrong approach with this class, i.e.
the wrong methodology for conversions between the Persian and Gregorian
calendar. Could somebody possibly have a look at the class and tell me
what I should be doing instead?
Kind regards,
Steve.