Hijri / Arabic Date Control

366 views
Skip to first unread message

Khan

unread,
Feb 9, 2007, 3:28:33 PM2/9/07
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,
How can i display vb.net calendar control in hijri / arabic
dates. I tried to change all regional settings etc. it is displaying
in arabic but those are gregorian dates, i want to display hijri dates
either in english or arabic.

Thanx,

Khan.

Muhammed Shameem Siddique

unread,
Feb 10, 2007, 5:38:44 AM2/10/07
to DotNetDe...@googlegroups.com
Khan I wrote a HijriDateValidatorClass
 
just check the flow and customize according to ur Requirement
 
<Code>

public

static class HisHijriDateValidator

{

/// <summary>

/// HijriCalendar.

/// </summary>

private static HijriCalendar hjCalendar = new HijriCalendar();

/// <summary>

/// Returns the Validity of the Hijri Date.

/// </summary>

/// <param name="hijriDate">(ShortDate DD/MM/YYYY) HijriDate in String Format </param>

/// <returns>bool </returns>

public static bool ValidateHijriDate( string hijriDate)

{

return ValidateHijriDate(hijriDate, (hjCalendar.GetYear(AppCons.Now()) - 150));

}

/// <summary>

/// Returns the Validity of the Hijri Date.

/// </summary>

/// <param name="hijriDate">(ShortDate DD/MM/YYYY) HijriDate in String Format </param>

/// <param name="minimumYear">Minimum Year </param>

/// <returns>bool </returns>

public static bool ValidateHijriDate( string hijriDate, int minimumYear)

{

bool isValid = false;

int[] arrayHijriDate = GetHijriDateFromString(hijriDate);

int hijriDay = arrayHijriDate[0];

int hijriMonth = arrayHijriDate[1];

int hijriYear = arrayHijriDate[2];

int hjMonths = 0;

int hjDays = 0;

if (hijriYear >= minimumYear)

{

hjMonths = hjCalendar.GetMonthsInYear(hijriYear);

if (hijriMonth <= hjMonths && hijriMonth != 0)

{

hjDays = hjCalendar.GetDaysInMonth(hijriYear, hijriMonth);

if (!(hijriDay > hjDays || hijriDay == 0 || hijriDay < 0))

{

isValid =

true;

}

}

}

return isValid;

}

/// <summary>

/// Returns an Integer array of the Hijri Date

/// </summary>

/// <param name="hijriDate">Hijri Date as a string </param>

/// <returns>Array of Integers, Size of the Array being 3,

/// and the Date as DDMMYYY respectively to the Ascending order of the Array Index </returns>

private static int[] GetHijriDateFromString( string hijriDate)

{

char[] delimeter = { '/', '.' , '-' };

string[] splitHijriDate;

int[] intHijriDate = new int[3];

if (hijriDate != null && hijriDate.Length != 0)

{

splitHijriDate = hijriDate.Split(delimeter);

for (int iNdx = 0; iNdx < splitHijriDate.Length; iNdx++)

{

if (!(splitHijriDate[iNdx] == "0" || splitHijriDate[iNdx] == "00" || splitHijriDate[iNdx] == "000" || splitHijriDate[iNdx] == "0000" || splitHijriDate[iNdx] == ""))

{

intHijriDate[iNdx] =

Convert.ToInt32(splitHijriDate[iNdx]);

}

}

}

return intHijriDate;

}

}

</Code>

 

Muhammed Shameem Siddique

unread,
Feb 10, 2007, 5:40:37 AM2/10/07
to DotNetDe...@googlegroups.com
By the Way .....Its the Code of the HijriCalendar i have given u, Not a Control...

On 2/9/07, Khan <am...@programmer.net> wrote:

Khan

unread,
Feb 10, 2007, 3:03:48 PM2/10/07
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Ok shameem, let me try that one. I'll get back to you.

Thanx.

On 10 Feb, 03:40, "Muhammed Shameem Siddique"


<mscyberguest...@gmail.com> wrote:
> By the Way .....Its the Code of the HijriCalendar i have given u, Not a
> Control...
>

> On 2/9/07, Khan <a...@programmer.net> wrote:
>
>
>
> > Hi,
> > How can i display vb.net calendar control in hijri / arabic
> > dates. I tried to change all regional settings etc. it is displaying
> > in arabic but those are gregorian dates, i want to display hijri dates
> > either in english or arabic.
>
> > Thanx,
>
> > Khan.
>

> --
> Regards,
> Shameem

Reply all
Reply to author
Forward
0 new messages