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!
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
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.
I am from Pakistan, I used the code mentioned in the link, it works but one problem that it tells me date as 22 / 4 / 1444, where as it should be 21 / 4 / 1444.
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
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)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.