Hello everybody,
I was working on a script which gets the current date of the islamic calendar. I know there is a pip-module which converts a Georgian date to islamic date but it's only defined until 2077. I found there is a script on GitHub (https://github.com/gojigeje/hijri.sh) which gets the current date and it works far later than 2077.
The problem I have is that the bash script outputs the different results than when I "converted" the bash script to python. For example, this is the bash script for the current day (2 April 2023):
I was working on a script which gets the current date of the islamic calendar. I know there is a pip-module which converts a Georgian date to islamic date but it's only defined until 2077. I found there is a script on GitHub (https://github.com/gojigeje/hijri.sh) which gets the current date and it works far later than 2077.
The problem I have is that the bash script outputs the different results than when I "converted" the bash script to python. For example, this is the bash script for the current day (2 April 2023):
adjust=1 date=$(date +%d -d "$adjust day" | sed 's/^0*//') month=$(date +%m | sed 's/^0*//') year=$(date +%Y) a=$(( $(( $month-14)) / 12 )) b=$(( $(( $year+4900+$a )) / 100 )) c=$(( $(( 1461 * $(( $year+4800+$a )) )) / 4 )) d=$(( $(( 367 * $(( $month-2-12*$a )) )) / 12 ))This is the output for the bash script when I echo the results:
3 4 2023 0 69 2492100 61This is my python script:
#!/usr/bin/env Python3 #Imports from datetime import datetime import sys #Get Date day = datetime.now().day + 1 #Why adjust one date month = datetime.now().month year = datetime.now().year #Formula a = ((month-14) / 12) b = ((year+4900+math.trunc(a)) / 100) c = ((1461*(year+4800+a)) / 4) d = ((367 * (month-2-12*a)) / 4)And this is the output I get for day, month and year and a, b, c and d:
3 4 2023 -0.8333333333333334 69.23 2491796.375 1101.0Does anybody why the results of my python script differ so much to the ones from the bash script?