from Time import * def main(): print("Please give me a valid time.") h = int(input("Enter hour (1-12): ")) m = int(input("Enter minute (0-59) : ")) s = int(input("Enter second (0-59) : ")) a = input("Enter AM or PM : ") print(a) time = Time(h,m,s,a) print("\nThe time you entered is " + str(time)) while True: menu() option = input("Enter your option: ").lower() if option == "a": n = int(input("Enter number of seconds to add to the date: ")) print("\nThe time obtained after adding " + str(n) + " seconds to " + str(time) + " is " + str(time.add(n))) elif option == "s": n = int(input("Enter number of days to subtract from the date: ")) print("\nThe time obtained after subtracting " + str(n) + " seconds from " + str(time) + " is " + str(time.sub(n))) elif option == "p": print("\nThe time 1 second previous to " + str(time) + " is " + str(time.previous())) elif option == "n": print("\nThe time 1 second after " + str(time) + " is " + str(time.next())) elif option == "b": print("Please give me another valid time.") h = int(input("Enter hour (1-12): ")) m = int(input("Enter minute (0-59) : ")) s = int(input("Enter second (0-59) : ")) a = input("Enter AM or PM : ") time2 = Time(h,m,s,a) interval = time.seconds_between(time2) print("\nThe interval between " + str(time) + " and " + str(time2) + \ " is " + str(interval//60) + " minutes and "+ str(interval%60) + " seconds") elif option == "c": print("Please give me another valid time.") h = int(input("Enter hour (1-12): ")) m = int(input("Enter minute (0-59) : ")) s = int(input("Enter second (0-59) : ")) a = input("Enter AM or PM : ") time2 = Time(h,m,s,a) if time.before(time2): print("\n" + str(time) + " is before " + str(time2)) elif time.after(time2): print("\n" + str(time) + " is after " + str(time2)) else: print("\n" + str(time) + " is same as " + str(time2)) elif option == "q": break else: print("Invalid Option") def menu(): print("\n Welcome to Time Tester\n") print("(a) Add seconds to the time. ") print("(s) Subtract seconds from time. ") print("(p) Previous Second. ") print("(n) Next Second. ") print("(b) Interval between. ") print("(c) Compare Times to see if one is before another. ") print("(q) Quit. ") print() main()