Skip to content

Instantly share code, notes, and snippets.

@sugiana
Created October 30, 2017 01:49
Show Gist options
  • Save sugiana/fc4553483e50504ffe06987d2c8fe1a1 to your computer and use it in GitHub Desktop.
Save sugiana/fc4553483e50504ffe06987d2c8fe1a1 to your computer and use it in GitHub Desktop.
Tanggal Jatuh Tempo
from datetime import date
def bulan_depan(bulan, tahun):
if bulan == 12:
bulan_b = 1
tahun_b = tahun + 1
else:
bulan_b = bulan + 1
tahun_b = tahun
return bulan_b, tahun_b
def tgl_jatuh_tempo(bulan, tahun):
bulan_b, tahun_b = bulan_depan(bulan, tahun)
return date(tahun_b, bulan_b, 25)
if __name__ == '__main__':
contoh = [
(10, 2017),
(12, 2017),
]
for bulan, tahun in contoh:
tgl = tgl_jatuh_tempo(bulan, tahun)
s = '{b} {t} -> {tgl}'.format(b=bulan, t=tahun, tgl=tgl)
print(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment