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...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 2nd of May 2008 09:26:51 AM Download | Raw | Embed | Report
  1. from mx import DateTime as DT
  2.  
  3. def getDate():
  4.     dstr = raw_input("Enter date as year, month, day; or enter nothing for today: ")
  5.     if dstr == "":
  6.         return DT.now()
  7.     else:
  8.         dstr = dstr.split(',')
  9.         year, month, day = int(dstr[0]), int(dstr[1]), int(dstr[2])
  10.         return DT.Date(year, month, day)
  11.    
  12. def getDiff():
  13.     print "Enter positive int for days after date; negative int for days before date."
  14.     return int(raw_input("Enter the number of days: "))
  15.  
  16. def printDate(date):
  17.     print "Date entered was", str(date)[:10]
  18.    
  19. def printDatePlusN(date, n):
  20.     plus_minus = ""
  21.     if n >= 0:
  22.         plus_minus = "plus"
  23.     else:
  24.         plus_minus = "minus"
  25.     print "%s %s %s days is %s" % (str(date)[:10], plus_minus, str(abs(n)),
  26.         str(date + n)[:10])
  27.  
  28. def main():
  29.     date = getDate()
  30.     printDate(date)
  31.     n = getDiff()
  32.     printDatePlusN(date, n)
  33.  
  34. if __name__ == '__main__':
  35.     main()
  36.    
  37.  
  38. """
  39. sample output:
  40. =============================================
  41. Enter date as year, month, day; or enter nothing for today:
  42. Date entered was 2008-05-02
  43. Enter positive int for days after date; negative int for days before date.
  44. Enter the number of days: -100000
  45. 2008-05-02 minus 100000 days is 1734-07-18
  46. =============================================
  47. """
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: