Skip to content

Instantly share code, notes, and snippets.

@altilunium
Last active March 8, 2021 15:38
Show Gist options
  • Save altilunium/37b4462e3c18d45c63537c7a2dcad72f to your computer and use it in GitHub Desktop.
Save altilunium/37b4462e3c18d45c63537c7a2dcad72f to your computer and use it in GitHub Desktop.
timetable
import math
from datetime import datetime
cmonth = datetime.now().month
day = datetime.now().day
print("Bulan "+ str(cmonth))
print("Hari" +str(day))
#Masukkan longtiude (west = negative)
lamd = 102.99793
#Masukkan latitude (south = negative)
phi = -6.09564
#Masukkan zona waktu (GMT+/-)
td = 7
rad = 3.14159 / 180
lamd = (lamd / 360) * 24
phi = phi * rad
n0 = 0
def something():
global x, tloc,st
t = n + ((a - lamd)/24)
m = ((0.9856*t) - 3.289)*rad
l = m + (1.916*rad*math.sin(m)) + (0.02*rad*math.sin(2*m)) + (282.634*rad)
lh = (l/3.14159)*12
ql = int(lh/6) + 1
if ((int(ql/2)*2)-ql) != 0:
ql = ql -1
ra = math.atan(0.91746*math.tan(l))/3.14159*12
ra = ra + (ql*6)
sind = 0.39782*math.sin(l)
cosd = math.sqrt(1-sind*sind)
x = (math.cos(z) - sind*math.sin(phi))/(cosd*math.cos(phi))
if abs(x) > 1:
return
else:
atnx = math.atan(math.sqrt(1-x*x)/x)/rad
if atnx < 0:
atnx = atnx + 180
h = (360-atnx)*24/360
if a == 18:
h = 24-h
tloc = h + ra - (0.06571*t) - 6.622
tloc = tloc + 24
tloc = tloc - (int(tloc/24)*24)
st = tloc - lamd + td
month = [31,28,31,30,31,30,31,31,30,31,30,31]
currentmonth = 1
currentday = 0
for d in month:
for k in range(1,d+1):
t = [0,0,0,0,0,0]
currentday = currentday + 1
#n = n0 + k
n = currentday
#subuh azimut 108
a = 6
z = 108*rad
something()
if abs(x) <= 1:
t[0] = st
#sunrise azimut 90+5/6
z = (90+5/6)*rad
something()
t[1] = st
#sunset azimut 90+5/6
a = 18
z = (90+5/6)*rad
something()
sunset = st
#magrib = sunset + toleransi 2/60
t[4] = st + 2/60
#isya azimut 108
z = 108*rad
something()
if abs(x) <= 1:
t[5] = st
#midday = (sunrise + sunset)/2
midday = (t[1] + sunset)/2
#zuhur = midday + padding 2/60
t[2] = midday + 2/60
#ashar = (zuhur + magrib)/2
t[3] = (t[2] + t[4])/2
#if (k == day) and (currentmonth == cmonth):
if (currentmonth == cmonth):
print(str(k)+"\t",end='')
for jadwal in t:
th = int(jadwal)
tm = int((jadwal-th)*60)
print(str(th)+":"+str(tm)+"\t",end='')
print("\n")
currentmonth = currentmonth + 1
@altilunium
Copy link
Author

altilunium commented Mar 8, 2021

image

Perhitungan waktu dengan koordinat Kota Bekasi pada bulan Maret
Kiri : Data Kemenag Jakarta Pusat
Kanan : Program Ini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment