Something tells me that Hijri calendar, or "Islamic calendar" might be not supported by .NET in its standard way, through
ToString(IFormatProvider)
or
System.DateTime.ToString(String, IFormatProvider)
, if you used the implementation of the interface
System.IFormatProvider
as it is implemented by the type
System.Globalization.CultureInfo
, as it is usually done.
Please see:
http://msdn.microsoft.com/en-us/library/ht77y576.aspx[
^],
http://msdn.microsoft.com/en-us/library/8tfzyc64.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.iformatprovider.aspx[
^].
I think, at least one background reason of such state of affairs is that the format providers based on particular cultures, are based on cultural preferences related to certain nations, or group of nations sharing some cultural elements such as language, but Islamic cultural traditions are pretty much international and only partially integrate in national cultures. You can take a chance of trying particular cultures of some
Muslim countries, but I don't think that Hijri dominates even there to the extent that it can be included in the standard. You could just try though:
http://en.wikipedia.org/wiki/Hijri[
^],
http://en.wikipedia.org/wiki/List_of_Muslim-majority_countries[
^].
The code sample for such approach is shown in a MSDN article I referenced above, very first link; you can quickly try all country-based Islamic cultures, but I don't think you will find the case formatting as Hijri. So, even though I'm to best of my knowledge, you won't success in using just .NET Base Class Library (BCL), so you will need to apply fully custom approach.
First of all, you can develop a Hijri-specific of the
System.IFormatProvider
by yourself. In a more
ad-hoc approach, you can simply develop your own variant of
System.DateTime.ToString
which could be as simple as having something like
string TimeToHijriString(System.DateTime time /* , some options? */)
. All you would need is the description of the calendar I referenced above, plus using individual fields of
System.DateTime.ToString
for year, month, etc.:
http://msdn.microsoft.com/en-us/library/system.datetime.aspx[
^].
As the Hijri also has 12 months per year, 7 days a week, I hope you can map it to the Gregorian calendar (known to all computer systems,
http://en.wikipedia.org/wiki/Gregorian_calendar[
^]) pretty well, without big problems.
Wish you the best of luck,
—SA