Created
October 30, 2017 02:03
-
-
Save sugiana/d511018ba2653f93064bc1e47b291b54 to your computer and use it in GitHub Desktop.
Jatuh Tempo dengan Input Tanggal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(tgl): | |
bulan_b, tahun_b = bulan_depan(tgl.month, tgl.year) | |
return date(tahun_b, bulan_b, 25) | |
if __name__ == '__main__': | |
contoh = [ | |
date(2017, 10, 1), | |
date(2017, 12, 28), | |
] | |
for a in contoh: | |
b = tgl_jatuh_tempo(a) | |
s = '{a} -> {b}'.format(a=a, b=b) | |
print(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment