none
Hijri Calendar Class RRS feed

  • Question

  • Dear all,

    I am working with hijri calendar.

    1. does this calendar class updated Automatically based on new moon seen,?

        because now ramadan 29 days and it returns first , last date of shawwal correct

    2. why Hijri adjustment property valid values between -2 and 2?


    Monday, July 20, 2015 6:26 AM

Answers

  • Dear Gaurav,

    I am working on system that calculate salaries based on Hijri calendar,

    and i allow user to change last date of any month => adjustment may exceed 2 if all 29 days months become 30

    days , and this violate adjustment property

    Hi Riham ,

    For question 1:

    I also tried to test on my side, using the sample from MSDN.  Given the data time is 1/29 1422, please check the following sample for more details.

     // Creates and initializes a HijriCalendar.
                HijriCalendar myCal = new HijriCalendar();
    
                // Creates a DateTime and initializes it to the second day of the first month of the year 1422.
                DateTime myDT = new DateTime(1422, 1, 29, myCal);
    
                // Displays the current values of the DateTime.
                Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment);
                Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT));
                Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT));
                Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT));
    
                // Sets the HijriAdjustment property to 2.
                myCal.HijriAdjustment = 2;
                Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment);
                Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT));
                Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT));
                Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT));
    
                // Sets the HijriAdjustment property to -2.
                myCal.HijriAdjustment = -2;
                Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment);
                Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT));
                Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT));
                Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT));

    Here is my test result.

    2. why Hijri adjustment property valid values between -2 and 2?

    It is by design, Please check HijriCalendar.HijriAdjustment Property for more details.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, July 22, 2015 3:23 AM

All replies

  • Following link may help

    https://msdn.microsoft.com/en-us/library/system.globalization.hijricalendar(v=vs.110).aspx


    Gaurav Khanna | Microsoft .NET MVP | Microsoft Community Contributor

    Monday, July 20, 2015 6:32 AM
  • I follow this link, but the problem it shows ramadan 30 days and now it 29 days, 

    the hijri calendar return 1/10/1436 as 17/07/2015 without any adjustment!!!!

    Monday, July 20, 2015 6:43 AM
  • I guess you need to check HijriAdjustment property.

    https://msdn.microsoft.com/en-us/library/system.globalization.hijricalendar.hijriadjustment(v=vs.110).aspx


    Gaurav Khanna | Microsoft .NET MVP | Microsoft Community Contributor

    Monday, July 20, 2015 7:15 AM
  • Dear Gaurav,

    I am working on system that calculate salaries based on Hijri calendar,

    and i allow user to change last date of any month => adjustment may exceed 2 if all 29 days months become 30

    days , and this violate adjustment property

    Monday, July 20, 2015 8:15 AM
  • Dear Gaurav,

    I am working on system that calculate salaries based on Hijri calendar,

    and i allow user to change last date of any month => adjustment may exceed 2 if all 29 days months become 30

    days , and this violate adjustment property

    Hi Riham ,

    For question 1:

    I also tried to test on my side, using the sample from MSDN.  Given the data time is 1/29 1422, please check the following sample for more details.

     // Creates and initializes a HijriCalendar.
                HijriCalendar myCal = new HijriCalendar();
    
                // Creates a DateTime and initializes it to the second day of the first month of the year 1422.
                DateTime myDT = new DateTime(1422, 1, 29, myCal);
    
                // Displays the current values of the DateTime.
                Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment);
                Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT));
                Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT));
                Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT));
    
                // Sets the HijriAdjustment property to 2.
                myCal.HijriAdjustment = 2;
                Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment);
                Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT));
                Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT));
                Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT));
    
                // Sets the HijriAdjustment property to -2.
                myCal.HijriAdjustment = -2;
                Console.WriteLine("HijriAdjustment is {0}.", myCal.HijriAdjustment);
                Console.WriteLine("   Year is {0}.", myCal.GetYear(myDT));
                Console.WriteLine("   Month is {0}.", myCal.GetMonth(myDT));
                Console.WriteLine("   Day is {0}.", myCal.GetDayOfMonth(myDT));

    Here is my test result.

    2. why Hijri adjustment property valid values between -2 and 2?

    It is by design, Please check HijriCalendar.HijriAdjustment Property for more details.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Wednesday, July 22, 2015 3:23 AM