Created
August 27, 2011 12:26
-
-
Save toomore/1175325 to your computer and use it in GitHub Desktop.
退伍計算
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from datetime import datetime | |
from datetime import timedelta | |
intime = datetime(2011,02,15) # 入伍時間 | |
outtime = datetime(2012,01,16) # 退伍時間 | |
def cd(d): | |
''' 倒數天數 ''' | |
tod = outtime - timedelta(d) | |
tods = tod - datetime.today() | |
return (tod.date(),tods.days) | |
alldays = outtime- intime | |
print " - 退伍倒數:%s 天" % (outtime-datetime.now()).days | |
print " - 役期天數:%s 天" % alldays.days | |
print " - 行程:%.2f%%" % float(float((datetime.now()-intime).days)/alldays.days*100) | |
print " - 100 日:%s (距離 100 日:%3s 天)" % cd(100) | |
print " - 50 日:%s (距離 50 日:%3s 天)" % cd(50) | |
print " - 25 日:%s (距離 25 日:%3s 天)" % cd(25) | |
print " - 10 日:%s (距離 10 日:%3s 天)" % cd(10) | |
print " - 5 日:%s (距離 5 日:%3s 天)" % cd(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment