Subdomain Posts
Recent Posts
OCaml | 1 sec ago
HTML | 3 sec ago
None | 7 sec ago
None | 8 sec ago
JavaScript | 19 sec ago
OCaml | 21 sec ago
None | 23 sec ago
JavaScript | 28 sec ago
None | 38 sec ago
JavaScript | 38 sec ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
By Anonymous on the 2nd of May 2008 09:26:51 AM
Download |
Raw |
Embed |
Report
from mx import DateTime as DT
def getDate():
dstr = raw_input("Enter date as year, month, day; or enter nothing for today: ")
if dstr == "":
return DT.now()
else:
dstr = dstr.split(',')
year, month, day = int(dstr[0]), int(dstr[1]), int(dstr[2])
return DT.Date(year, month, day)
def getDiff():
print "Enter positive int for days after date; negative int for days before date."
return int(raw_input("Enter the number of days: "))
def printDate(date):
print "Date entered was", str(date)[:10]
def printDatePlusN(date, n):
plus_minus = ""
if n >= 0:
plus_minus = "plus"
else:
plus_minus = "minus"
print "%s %s %s days is %s" % (str(date)[:10], plus_minus, str(abs(n)),
str(date + n)[:10])
def main():
date = getDate()
printDate(date)
n = getDiff()
printDatePlusN(date, n)
if __name__ == '__main__':
main()
"""
sample output:
=============================================
Enter date as year, month, day; or enter nothing for today:
Date entered was 2008-05-02
Enter positive int for days after date; negative int for days before date.
Enter the number of days: -100000
2008-05-02 minus 100000 days is 1734-07-18
=============================================
"""
Submit a correction or amendment below.
Make A New Post