msarhan / ummalqura-calendar

Implementation of java.util.Calendar for the Umm Al-Qura calendar system.
MIT License
154 stars 51 forks source link

Invalid Hijrah day of month: 30 #35

Open atifaziz1 opened 1 year ago

atifaziz1 commented 1 year ago

I am facing issue that hijrah date is invalid.. This error is exist in both version 2.0.1 and 2.0.2.

Any help.? @msarhan @alhazmy13

Screenshot 2022-11-24 at 11 31 00 AM

Error Screen shot is attached.

alhazmy13 commented 1 year ago

@atifaziz1 I think you are parsing the date in the wrong way; you cannot set the month to 30. Can you share your code?

atifaziz1 commented 1 year ago

@alhazmy13 Thanks for your quick response.

Here is my code

UmmalquraCalendar now = new UmmalquraCalendar();

HijriDatePickerDialog hijriDatePickerDialog = HijriDatePickerDialog.newInstance(listener,now.get(UmmalquraCalendar.YEAR), now.get(UmmalquraCalendar.MONTH), now.get(UmmalquraCalendar.DAY_OF_MONTH));`

atifaziz1 commented 1 year ago

@alhazmy13 If i do

UmmalquraCalendar now = new UmmalquraCalendar(); HijriDatePickerDialog hijriDatePickerDialog = HijriDatePickerDialog.newInstance(listener, now.get(Calendar.YEAR), now.get(Calendar.MONTH),now.get(Calendar.DAY_OF_MONTH));

I am getting com.github.msarhan.ummalqura.calendar.DateTimeException: Invalid Hijrah day of month: 31 error

atifaziz1 commented 1 year ago

@msarhan please help required. It's urgent.

alhazmy13 commented 1 year ago

@atifaziz1 I believe this related to HijriDatePicker it could be using an old version of UmmalquraCalendar or something like that, ill dig deep on the library to find the root case of this issue

atifaziz1 commented 1 year ago

@alhazmy13 I hope you will fix this issue on priority bases. Thanks.

alhazmy13 commented 1 year ago

Yes sir @atifaziz1 , you are using the library in the wrong way, please update your code to below:

UmmalquraCalendar now = new UmmalquraCalendar();
HijriDatePickerDialog dpd = HijriDatePickerDialog.newInstance(
          this,
          now.get(UmmalquraCalendar.YEAR),
          now.get(UmmalquraCalendar.MONTH),
          now.get(UmmalquraCalendar.DAY_OF_MONTH));
dpd.show(getFragmentManager(), "HijriDatePickerDialog");

more details: https://github.com/alhazmy13/HijriDatePicker#create-a-hijridatepickerdialog

atifaziz1 commented 1 year ago

Dear @alhazmy13 !

Please look at my first comment, i am writing the code same as you mentioned.

UmmalquraCalendar now = new UmmalquraCalendar();

HijriDatePickerDialog hijriDatePickerDialog = HijriDatePickerDialog.newInstance(listener,
now.get(UmmalquraCalendar.YEAR), 
now.get(UmmalquraCalendar.MONTH),
 now.get(UmmalquraCalendar.DAY_OF_MONTH));`
AhmedElsayedTaha commented 7 months ago

@atifaziz1 Did you fixed it ? I'm stuck at this error

AhmedElsayedTaha commented 7 months ago

@msarhan @alhazmy13 Hello , I have the same exception when I choose day 30 from any month then choose day 29 from another month I get this exception . I use version 2.0.2

Here is my code

 private fun showHijriDatePicker(
        editText: TextInputEditText,
        isFromDatePicker: Boolean = false
    ) {
        val datePicker = HijriDatePickerDialog.newInstance(
            { _, year, monthOfYear, dayOfMonth ->
                when (isFromDatePicker) {
                    true -> {
                        fromDateValue = formatHijriDate(year, monthOfYear, dayOfMonth)
                    }
                    false -> {
                        toDateValue = formatHijriDate(year, monthOfYear, dayOfMonth)
                    }
                }
                editText.setText(formatHijriDate(year, monthOfYear, dayOfMonth))
            },
            ummalquraCalendar.get(UmmalquraCalendar.YEAR),
            ummalquraCalendar.get(UmmalquraCalendar.MONTH),
            ummalquraCalendar.get(UmmalquraCalendar.DAY_OF_MONTH)
        )
}

image