Windows 10 added support for the Jalali calendar.
As a result, the
DateTimeFormatInfo Class (System.Globalization)[
^] class should return different date format strings for "fa-Ir" when called on Windows 10 and older versions (can not test it here).
At first you have to observe that your date string is Jalali while
DateTime
objects use the Gregorian calendar.
To get the Gregorian date from a Jalali date use the
ToDateTime
method of the
PersianCalendar Class (System.Globalization)[
^].
But before that conversion you have to parse the string. The first approach coming into mind is using
DateTime.Parse
with the fixed format "yyyy/MM/dd". But this will fail for specific dates. So you have to split the string into the year, month, and day parts.
Untested example without parse error checking:
String[] dateParts = s.Split('/');
int year = int.Parse(dateParts[0]);
int month = int.Parse(dateParts[1]);
int day = int.Parse(dateParts[2]);
PersianCalendar pc = new PersianCalendar();
DateTime dt = pc.ToDateTime(year, month, day, 0, 0, 0, 0);