Skip to content

Instantly share code, notes, and snippets.

@toomore
Created August 27, 2011 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomore/1175325 to your computer and use it in GitHub Desktop.
Save toomore/1175325 to your computer and use it in GitHub Desktop.
退伍計算
#!/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