pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

py77.python private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Anonymous on Fri 2 May 13:20
report abuse | download | new post

  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.         return DT.Parser.DateFromString(dstr)
  9.    
  10. def getDiff():
  11.     print "Enter positive int for days after date; negative int for days before date."
  12.     return int(raw_input("Enter the number of days: "))
  13.  
  14. def printDate(date):
  15.     print "Date entered was", date.strftime("%m/%d/%Y")
  16.    
  17. def printDatePlusN(date, n):
  18.     plus_minus = ""
  19.     if n >= 0:
  20.         plus_minus = "plus"
  21.     else:
  22.         plus_minus = "minus"
  23.     print "%s %s %s days is %s" % (date.strftime("%m/%d/%Y"), plus_minus, str(abs(n)),
  24.         (date + n).strftime("%m/%d/%Y"))
  25.  
  26. def main():
  27.     date = getDate()
  28.     printDate(date)
  29.     n = getDiff()
  30.     printDatePlusN(date, n)
  31.  
  32. if __name__ == '__main__':
  33.     main()
  34.    
  35.  
  36. """
  37. =============================================
  38. Enter date as year, month, day; or enter nothing for today:
  39. Date entered was 05/02/2008
  40. Enter positive int for days after date; negative int for days before date.
  41. Enter the number of days: -100000
  42. 05/02/2008 minus 100000 days is 07/18/1734
  43. =============================================
  44.  
  45. """

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me