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 10:26
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.         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 (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