B4A Class Hijri date Calendar

A modification on AnotherDatePicker class and adding this code and some other modifications, we get class for Hijri Calendar picker.
hijri.jpg
 

Attachments

  • AnotherDatePicker.bas
    10.7 KB · Views: 119
  • datepicker.bal
    8.5 KB · Views: 118
  • hijricalendarExample.zip
    15.3 KB · Views: 140
Last edited:

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
I completed modification of XUI views + B4XPreferenceDialog to work with Hijri date picker, I changed their names to avoid conflict with original ones, they are work fine and pick Hijri Calendar ...
BUT
What is the function inside XUI Views>B4XDateTemplate.bas that return the selected date to B4XPreferencedialog prefdateitem after user select day?
I trying a lot of time, I'm confused! I tried Sub SelectDay but with no success!
 

William Lancee

Well-Known Member
Licensed User
Longtime User
Have you tried? (from @Erel tutorial on xui views)
B4X:
    Wait For (Dialog.ShowTemplate(DateTemplate, "", "", "CANCEL")) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        btnDate.xLBL.Text = DateTime.Date(DateTemplate.Date)
    End If
 

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
I conclude that Hijri Date can't converted to Long format as Gregorian Date Type.
I think this conclusion applied for other non-gregorian dates.
Use above class for Hijri date picker, then convert it to corresponding Gregorian date.
 

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
here
B4X:
Sub GregorianToHijri(TheDate As Long) As List
    Dim jd As Long
    Dim I As Long
    Dim N As Long
    Dim J As Long
  

    Dim D As Long
    Dim M As Long
    Dim Y As Long

    D = DateTime.GetDayOfMonth( TheDate)
    M = DateTime.getMonth(TheDate)
    Y = DateTime.GetYear(TheDate)
    If ((Y > 1582) Or ((Y = 1582) And (M > 10)) Or ((Y = 1582) And (M = 10) And (D > 14))) Then
        jd = Fix((1461 * (Y + 4800 + Fix((M - 14) / 12))) / 4) + Fix((367 * (M - 2 - 12 * (Fix((M - 14) / 12)))) / 12) - Fix((3 * (Fix((Y + 4900 + Fix((M - 14) / 12)) / 100))) / 4) + D - 32075
    Else
        jd = 367 * Y - Fix((7 * (Y + 5001 + Fix((M - 9) / 7))) / 4) + Fix((275 * M) / 9) + D + 1729777
    End If
    I = jd - 1948440 + 10632
    N = Fix((I - 1) / 10631)
    I = I - 10631 * N + 354
    J = (Fix((10985 - I) / 5316)) * (Fix((50 * I) / 17719)) + (Fix(I / 5670)) * (Fix((43 * I) / 15238))
    I = I - (Fix((30 - J) / 15)) * (Fix((17719 * J) / 50)) - (Fix(J / 16)) * (Fix((15238 * J) / 43)) + 29
    M = Fix((24 * I) / 709)
    D = I - Fix((709 * M) / 24) -1
    Y = 30 * N + J - 30
    Return Array (Y,M,D)
End Sub


Sub Fix(arg As Int) As Int
    Return Ceil(arg )
End Sub
 

Alhootti

Member
Im using this code to convert from Hijri to Gregorian, but it is not working
B4X:
EditText1.Text = HijriToGregorian(1444,09,01)
 

Alhootti

Member
we know the Ramadan will be at 01/09/1444 Hiri
Is there Accurate way to calculate How many days left for Ramadan from today
 

Alhootti

Member
I solved it by using this code
Dim Meladi As List = HijriConverter.HijriToGregorian("1444","09","01" )
Label1.Text = Meladi.Get(2) & "/" & NumberFormat(Meladi.Get(1), 2 ,0) & "/" & NumberFormat(Meladi.Get(0), 2 ,0)
 
Top