Persian Calendar Class simple conversion problem

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top