Convert macro to calc-Add-In

Hello.

I have a macro that adds the Solar Hijri calendar to the Calc, but using a macro has its potential risks. Therefore, it is better to convert the functions of this macro into a Add-in of Calc.
Unfortunately, I know nothing about programming.
I know it’s a lot to ask, but would it be possible for you to turn this macro into a Add-in for me to add Solar Hijri calendar functions to the spreadsheet?

Public strDate As String
'//////////////////////////////////////
'ماژول اصلاح‌شدهٔ جناب آزادی توسط احمد میرزازاده به تاریخ 1388/7/22
' 1- تعریف کنید Number(Long) است را بصورت Date فیلدهایی که نوع آن‌ها
' 2- این فیلدها را بصورت 0000/00/00 تنظیم کنید InputMask خاصیت
' بدلیل 8 رقمی در نظر گرفتن فیلد تاریخ ، این توابع تا سال 1999 کارایی دارد
' ...
' تاریخ جاری سیستم را به هجری شمسی تبدیل می‌کند Shamsi() تابع
' به‌کار ببرید Now() را می توانید در گزارشات بجای تابع Dat() تابع
' :برای جلوگیری از ورود تاریخ غلط به درون یک فیلد بترتیب زیر عمل می‌کنید
' :به‌شکل زیر به‌کار ببرید ValidationRule را در خاصیت ValidDate() تابع
' ...
' ************************************************** ***********
Public Function Rooz(F_Date As Long) As Byte
'این تابع عدد مربوط به روز یک تاریخ را برمی‌گرداند
Rooz = F_Date Mod 100
End Function
'*******************************************
Function Mah(F_Date As Long) As Byte
'این تابع عدد مربوط به ماه یک تاریخ را برمی‌گرداند
Mah = Int((F_Date Mod 10000) / 100)
End Function
'*******************************************
Public Function Sal(F_Date As Long) As Integer
'این تابع عدد مربوط به سال یک تاریخ را برمی‌گرداند
Sal = Int(F_Date / 10000)
End Function
'*******************************************
Public Function Kabiseh(ByVal OnlySal As Variant) As Byte
'ورودی تابع عدد دورقمی است
'این تابع کبیسه بودن سال را برمی‌گرداند
'اگر سال کبیسه باشد، عدد یک و درغیر اینصورت صفر را برمی‌گرداند
Kabiseh = 0
If OnlySal >= 1375 Then
If (OnlySal - 1375) Mod 4 = 0 Then
Kabiseh = 1
Exit Function
End If
ElseIf OnlySal <= 1370 Then
If (1370 - OnlySal) Mod 4 = 0 Then
Kabiseh = 1
Exit Function
End If
End If

End Function
'*******************************************
Function ValidDate(F_Date As Long) As Boolean
Dim M, s, R As Byte
' این تابع اعتبار یک عدد ورودی را از نظر تاریخ هجری شمسی بررسی می‌کند
' را برمی‌گرداند False واگر نامعتبر باشد True اگر تاریخ معتبر باشد
ValidDate = True

s = Sal(F_Date)
M = Mah(F_Date)
R = Rooz(F_Date)
'********
If F_Date < 10000101 Then
ValidDate = False
Exit Function
End If

If M > 12 Or M = 0 Or R = 0 Then
ValidDate = False
Exit Function
End If

If R > MahDays(s, M) Then
ValidDate = False
Exit Function
End If
End Function
'*******************************************
Public Function AddDay(ByVal F_Date As Long, ByVal Add As Integer) As Long
Dim K, M, R, Days As Byte
Dim s As Integer
R = Rooz(F_Date)
M = Mah(F_Date)
s = Sal(F_Date)
K = Kabiseh(s)

'تبدیل روز به عدد 1 جهت ادامهٔ محاسبات و یا اتمام محاسبه
Days = MahDays(s, M)
If Add > Days - R Then
Add = Add - (Days - R + 1)
R = 1
If M < 12 Then
M = M + 1
Else
M = 1
s = s + 1
End If
Else
R = R + Add
Add = 0
End If

While Add > 0
K = Kabiseh(s) 'کبیسه: 1 و غیر کبیسه: 0
Days = MahDays(s, M) 'تعداد روزهای ماه فعلی
Select Case Add
Case Is < Days
'اگر تعداد روزهای افزودنی کمتر از یک ماه باشد
R = R + Add
Add = 0
Case Days To IIf(K = 0, 365, 366) - 1
'اگر تعداد روزهای افزودنی بیشتر از یک ماه و کمتر از یک سال باشد
Add = Add - Days
If M < 12 Then
M = M + 1
Else
s = s + 1
M = 1
End If
Case Else
'اگر تعداد روزهای افزودنی بیشتر از یک سال باشد
s = s + 1
Add = Add - IIf(K = 0, 365, 366)
End Select
Wend
'AddDay = (s * 10000) + (M * 100) + (R)
AddDay = CLng(s & Format(M, "00") & Format(R, "00"))
End Function

'***********************************************
'original for excell Public Static Function Shamsi() As Long

Public Function Shamsi() As Long

'تاریخ جاری سیستم را به تاریخ هجری شمسی تبدیل می‌کند
Dim Shamsi_Mabna As Long
Dim Miladi_mabna As Date
Dim Dif As Long
'در اینجا 78/10/11 با 2000/01/01 معادل قرارداده شده
Shamsi_Mabna = 13781011
Miladi_mabna = #1/1/2000#
Dif = DateDiff("d", Miladi_mabna, Date)
If Dif < 0 Then
MsgBox "تاریخ جاری سیستم شما نادرست است. آن را اصلاح کنید."
Else
Shamsi = AddDay(Shamsi_Mabna, Dif)
End If
End Function
'***********************************************
Public Function miladibeshamsi(M_Date As Date) As Long
'تاریخ شمسی ورودی را به تاریخ میلادی تبدیل می‌کند
Dim Shamsi_Mabna As Long
Dim Miladi_mabna As Date
Dim Dif As Long
'در اینجا 78/10/11 با 2000/01/01 معادل قرارداده شده
Shamsi_Mabna = 13781011
Miladi_mabna = #1/1/2000#
Dif = DateDiff("d", Miladi_mabna, M_Date)
If Dif < 0 Then
MsgBox "تاریخ جاری سیستم شما نادرست است. آن را اصلاح کنید."
Else
miladibeshamsi = AddDay(Shamsi_Mabna, Dif)
End If
End Function
'***********************************************
Public Function shamsibemiladi(F_Date As Long) As Date
'تاریخ شمسی ورودی را به تاریخ میلادی تبدیل می‌کند
Dim Shamsi_Mabna As Long
Dim Miladi_mabna As Date
Dim Dif As Long
'در اینجا 78/10/11 با 2000/01/01 معادل قرارداده شده
Shamsi_Mabna = 13781011
Miladi_mabna = #1/1/2000#

if (ValidDate(F_Date)) then
Dif = Diff(Shamsi_Mabna,F_Date)
shamsibemiladi = Miladi_mabna + dif
else
shamsibemiladi = 0
end if
End Function
'***********************************************
Public Function DayWeek(F_Date As Long) As String
Dim a As String
Dim N As Byte
N = DayWeekNo(F_Date)
Select Case N
Case 0
a = "شنبه"
Case 1
a = "یکشنبه"
Case 2
a = "دوشنبه"
Case 3
a = "سه‌شنبه"
Case 4
a = "چهارشنبه"
Case 5
a = "پنج‌شنبه"
Case 6
a = "جمعه"
End Select
DayWeek = a
End Function

'***********************************************
Public Function Dat()
Dim d As Long
d = Shamsi
Dat = DayWeek(d) & "،" & " " & Sal(d) & "/" & Mah(d) & "/" & Rooz(d)
End Function

'***********************************************
Public Function Diff(ByVal FromDate As Long, ByVal To_Date As Long) As Long
'این تابع تعداد روزهای بین دو تاریخ را ارائه می‌کند
Dim Tmp As Long
Dim S1, M1, r1, S2, M2, r2 As Integer
Dim Sumation As Single
Dim Flag As Boolean
Flag = False
If FromDate = 0 Or IsNull(FromDate) = True Or To_Date = 0 Or IsNull(To_Date) = True Then
Diff = 0
Exit Function
End If

If FromDate > To_Date Then
'اگر تاریخ شروع از تاریخ پایان بزرگ‌تر باشد، آن‌ها موقتاً جابه‌جا می‌شوند
Flag = True
Tmp = FromDate
FromDate = To_Date
To_Date = Tmp
End If
r1 = Rooz(FromDate)
M1 = Mah(FromDate)
S1 = Sal(FromDate)
r2 = Rooz(To_Date)
M2 = Mah(To_Date)
S2 = Sal(To_Date)
Sumation = 0

Do While S1 < S2 - 1 Or (S1 = S2 - 1 And (M1 < M2 Or (M1 = M2 And r1 <= r2)))
'اگر یک سال یا بیشتر اختلاف بود
If Kabiseh((S1)) = 1 Then
If M1 = 12 And r1 = 30 Then
Sumation = Sumation + 365
r1 = 29
Else
Sumation = Sumation + 366
End If
Else
Sumation = Sumation + 365
End If
S1 = S1 + 1
Loop

Do While S1 < S2 Or M1 < M2 - 1 Or (M1 = M2 - 1 And r1 < r2)
'اگر یک ماه یا بیشتر اختلاف بود
Select Case M1
Case 1 To 6
If M1 = 6 And r1 = 31 Then
Sumation = Sumation + 30
r1 = 30
Else
Sumation = Sumation + 31
End If
M1 = M1 + 1
Case 7 To 11
If M1 = 11 And r1 = 30 And Kabiseh(S1) = 0 Then
Sumation = Sumation + 29
r1 = 29
Else
Sumation = Sumation + 30
End If
M1 = M1 + 1
Case 12
If Kabiseh(S1) = 1 Then
Sumation = Sumation + 30
Else
Sumation = Sumation + 29
End If
S1 = S1 + 1
M1 = 1
End Select
Loop

If M1 = M2 Then
Sumation = Sumation + (r2 - r1)
Else
Select Case M1
Case 1 To 6
Sumation = Sumation + (31 - r1) + r2
Case 7 To 11
Sumation = Sumation + (30 - r1) + r2
Case 12
If Kabiseh(S1) = 1 Then
Sumation = Sumation + (30 - r1) + r2
Else
Sumation = Sumation + (29 - r1) + r2
End If
End Select
End If

If Flag = True Then
Sumation = -Sumation
End If
Diff = Sumation
End Function

Public Function DayWeekNo(F_Date As Long) As String
'این تابع یک تاریخ را دریافت کرده و مشخص می‌کند چه روزی از هفته است
'اگر شنبه باشد عدد 0
'اگر 1شنبه باشد عدد 1
'......
'اگر جمعه باشد عدد 6
Dim day As String
Dim Shmsi_Mabna As Long
Dim Dif As Long
'مبنا 80/10/11
Shmsi_Mabna = 13801011
Dif = Diff(Shmsi_Mabna, F_Date)
If Shmsi_Mabna > F_Date Then
Dif = -Dif
End If
'با توجه به اینکه 80/10/11 3شنبه است محاسبه می‌شود day متغیر
day = (Dif + 3) Mod 7
If day < 0 Then
DayWeekNo = day + 7
Else
DayWeekNo = day
End If
End Function


Function MahName(ByVal Mah_no As Byte) As String
Select Case Mah_no
Case 1
MahName = "فروردین"
Case 2
MahName = "اردیبهشت"
Case 3
MahName = "خرداد"
Case 4
MahName = "تیر"
Case 5
MahName = "مرداد"
Case 6
MahName = "شهریور"
Case 7
MahName = "مهر"
Case 8
MahName = "آبان"
Case 9
MahName = "آذر"
Case 10
MahName = "دی"
Case 11
MahName = "بهمن"
Case 12
MahName = "اسفند"
End Select
End Function

Function SalMah(ByVal F_Date As Long) As Long
'شش رقم اول تاریخ که معرف سال و ماه است را برمی‌گرداند
SalMah = Val(Left$(F_Date, 6))
End Function

Function MahDays(ByVal Sal As Integer, ByVal Mah As Byte) As Byte
'این تابع تعداد روزهای یک ماه را برمی‌گرداند
Select Case Mah
Case 1 To 6
MahDays = 31
Case 7 To 11
MahDays = 30
Case 12
If Kabiseh(Sal) = 1 Then
MahDays = 30
Else
MahDays = 29
End If
End Select

End Function

Function Make_Date(ByVal F_Date As Long) As String
'یک تاریخ را به‌صورت یک رشتهٔ 10 رقمی با ذکر چهار رقم برای سال ارائه می‌کند
Dim d As String
d = Trim(Str(F_Date))
If IsNull(F_Date) = True Or F_Date = 0 Then
Make_Date = ""
Else
Make_Date = Mid(d, 1, 4) & "/" & Mid(d, 5, 2) & "/" & Mid(d, 7, 2)
End If
End Function

Function NextMah(ByVal Sal_Mah As Long) As Long
If (Sal_Mah Mod 100) = 12 Then
NextMah = (Int(Sal_Mah / 100) + 1) * 100 + 1
Else
NextMah = Sal_Mah + 1
End If
End Function

Function PreviousMah(ByVal Sal_Mah As Long) As Long
If (Sal_Mah Mod 100) = 1 Then
PreviousMah = (Int(Sal_Mah / 100) - 1) * 100 + 12
Else
PreviousMah = Sal_Mah - 1
End If
End Function


Function SubtractDay(ByVal F_Date As Long, ByVal Subtract As Long) As Long
'به‌تعداد روز معینی از یک تاریخ کم کرده و تاریخ حاصله را ارائه می‌کند
Dim K, M, s, R, Days As Byte

R = Rooz(F_Date)
M = Mah(F_Date)
s = Sal(F_Date)
K = Kabiseh(s)

'تبدیل روز به عدد 1 جهت ادامهٔ محاسبات و یا اتمام محاسبه
If Subtract >= R - 1 Then
Subtract = Subtract - (R - 1)
R = 1
Else
R = R - Subtract
Subtract = 0
End If

While Subtract > 0
K = Kabiseh(s - 1) 'کبیسه: 1 و غیر کبیسه: 0
Days = MahDays(IIf(M >= 2, s, s - 1), IIf(M >= 2, M - 1, 12)) 'تعداد روزهای ماه قبلی
Select Case Subtract
Case Is < Days
'اگر تعداد روزهای کاهش کمتر از یک ماه باشد
R = Days - Subtract + 1
Subtract = 0
If M >= 2 Then
M = M - 1
Else
s = s - 1
M = 12
End If
Case Days To IIf(K = 0, 365, 366) - 1
'اگر تعداد روزهای کاهش بیشتر از یک ماه و کمتر از یک سال باشد
Subtract = Subtract - Days
If M >= 2 Then
M = M - 1
Else
s = s - 1
M = 12
End If
Case Else
'اگر تعداد روزهای کاهش بیشتر از یک سال باشد
s = s - 1
Subtract = Subtract - IIf(K = 0, 365, 366)
End Select
Wend
SubtractDay = (s * 10000) + (M * 100) + (R)

End Function


'شمارهٔ اولین روز ماه
Public Function Firstday(Sal As Integer, Mah As Byte) As Long
Dim strfd As Long
strfd = Sal & Format(Mah, "00") & Format(1, "00")
Firstday = DayWeekNo(strfd)
End Function

You have to write add-in functions in a true programming language such as Python, C++, Java or JavaScript. Add-in functions are integrated in the Calc UI. They have to support UNO interfaces. This can’t be done in Basic.

2 Likes

Technically it can, using CreateUnoListener to implement the UNO interfaces. But indeed, it’s not documented, and better avoided.

Also, you can create the loader using other programming languages, but still use Basic code for the job, if you prefer.

Yes, but - just to mention the important consideration - use of C++ should be better avoided, because you would have to create platform-dependent binaries, while Python, Java and so on allow you to create cross-platform solutions (Python being the best, because it would avoid JRE dependency, which unfortunately still is the dependency for JavaScript, too).

3 Likes

A useful example add-in exposing Python’s string functions to Calc: Apache OpenOffice Community Forum - [Calc][oxt] A function for all python string methods - (View topic)
Install the oxt, restart office, open the example spreadsheet.

2 Likes

You can try this manual for an OXT extension Development/Create a Hello World LibreOffice extension - The Document Foundation Wiki

But it is also possible to calculate the Hijri date in one function, one function looks more friendly :-).

Sub showHijriDate
	msgbox getHijriDate() 'return actual hijri date
	msgbox getHijriDate(,-1) 'return hijri date with correction -1 day (the correction is needful if actual Ramadan is shortened or elongated with 1 day)
	msgbox getHijriDate(#1/14/2000#) 'return hijri date from some gregorian date
End Sub

Function getHijriDate(optional dnesek as date, optional pridatDen as integer) as string 'get Hijri date from gregorian date
	rem algorithm from Javascript: https://www.al-habib.info/islamic-calendar/hijricalendartext.htm
	dim  poleM(), rok, mesic, den, m, y, a, b, jd, jjd, bb, cc, dd, ee, irok, epochastro, epochcivil, shift1, cyc, z, j, iy, im, id, wd, myRes(8), s$
	if IsMissing(dnesek) then dnesek=Now
	if NOT IsMissing(pridatDen) then '+-1 day to gregorian date
		dnesek=DateAdd("d",pridatDen,Date)
	end if
	den=Day(dnesek) 'gregorian day
	mesic=Month(dnesek) 'gregorian month
	rok=Year(dnesek) 'gregorian year
	rem calculation
	m=mesic
	y=rok
	if m<3 then
		y=y-1
		m=m+12
	end if
	a=Fix(y/100)
	b=2-a+Fix(a/4)
	if y<1583 then b=0
	if y=1582 then
		if m>10 then b=-10
		if m=10 then
			b=0
			if den>4 then b=-10
		end if
	end if
	jd=Fix(365.25*(y+4716))+Fix(30.6001*(m+1))+den+b-1524
	b=0
	if jd>2299160 then
		a=Fix((jd-1867216.25)/36524.25)
		b=1+a-Fix(a/4)
	end if
	bb=jd+b+1524
	cc=Fix((bb-122.1)/365.25)
	dd=Fix(365.25*cc)
	ee=Fix((bb-dd)/30.6001)
	den=(bb-dd)-Fix(30.6001*ee)
	mesic=ee-1
	if ee>13 then
		cc=cc+1
		mesic=ee-13
	end if
	rok=cc-4716
	jjd=jd+1
	if not IsMissing(pridatDen) then jjd=jjd-pridatDen
	wd=1+((jjd\m)+7)\7
	irok=10631.0/30
	epochastro=1948084
	epochcivil=1948085
	shift1=8.01/60
	z=jd-epochastro
	cyc=Fix(z/10631)
	z=z-10631*cyc
	j=Fix((z-shift1)/irok)
	iy=30*cyc+j 'hijri year
	z=z-Fix(j*irok+shift1)
	im=Fix((z+28.5001)/29.5) 'hijri month
	if im=13 then im=12
	id=z-Fix(29.5001*im-29) 'hijri day
	rem variables: den = gregorian day; mesic = gregorian month; rok = gregorian
	'id = hijri day; im =hijri month; iy = hijri year
	getHijriDate=iy & "." & im & "." & id
End Function
1 Like

The Basic function distributed as part of an extension won’t work as a cell function. You have to copy the code into the special “Standard” library manually or programmatically.

1 Like

Just to mention it there is an extension available, as @afshin already knows.
So where is the difference to using the extension referenced here:

The function with LibreOffice API use:

Beginner users don’t know how to add this macro to a spreadsheet. In addition, because LibreOffice gives security errors before opening a macro, this causes them to avoid activating this macro.
In addition, this macro does not add Hijri functions to the list of functions, and the function must be typed manually every time.

Calc has a Persian Hijri number format.
Hijri.ods (12.8 KB)

No!
This is The Hijri calendar (Arabic: ٱلتَّقْوِيم ٱلْهِجْرِيّ, romanized: al-taqwīm al-hijrī)

Persian (Iranian) users use The Solar Hijri calendar [a] (Persian: گاه‌شماری هجری خورشیدی, romanized: Gâhšomâri-ye Hejri-ye Xoršidi)

I thought the Solar Hijri calendar is the same like standard islamic Hijri calendar, but now I read the differences - Persian Calendar . Next example is for standard Hijri calendar, but take it only as interestingness or a joke (I hope), it is not for practical usage :-). Unfortunately I don’t know how to help more.

I simplified the function for calculation and the formula for standard Hijri date is possible :-).
I don’t know if some mistakes aren’t there.

=IF((INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631)-INT((INT(( (INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631))-0,1335)/ (10631/30) ))* (10631/30) +0,1335)+28,5001)/29,5))=13;12;INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631)-INT((INT(( (INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631))-0,1335)/ (10631/30) ))* (10631/30) +0,1335)+28,5001)/29,5)) & "." & INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631)-INT((INT(( (INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631))-0,1335)/ (10631/30) ))* (10631/30) +0,1335)-INT(29,5001*(IF((INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631)-INT((INT(( (INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631))-0,1335)/ (10631/30) ))* (10631/30) +0,1335)+28,5001)/29,5))=13;12;INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631)-INT((INT(( (INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631))-0,1335)/ (10631/30) ))* (10631/30) +0,1335)+28,5001)/29,5)))-29) & "." & INT(30*(INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631))+INT(( (INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084-10631*INT((INT(365,25*(IF(MONTH($A$1)<3;YEAR($A$1)-1;YEAR($A$1))+4716))+INT(30,6001*(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))+1))+DAY($A$1)+IF(YEAR($A$1)<1583;0;IF(YEAR($A$1)=1582;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))>10;-10;IF(IF(MONTH($A$1)<3;MONTH($A$1)+12;MONTH($A$1))=10;IF(DAY($A$1)>4;-10;0);-10));2-INT(YEAR($A$1)/100)+INT(INT(YEAR($A$1)/100)/4)))-1524-1948084)/10631))-0,1335)/ (10631/30) ))

The example with macro I used
hijri-formulas1.ods (17.7 kB)