# import time
# # print(time.gmtime())
# # ##epoch time
# # print(time.gmtime(0))
# # print("="*40)
# # print(time.localtime())
# # print("="*40)
# # ##seconds till now from epoch time
# # print(time.time())
#
# time_here = time.localtime()
# print(time_here)
# #time_here is a tuple ,we can make use of the tuple index or name ,so that
# #we can get the desired part of the date
# print("year:",time_here[0],time_here.tm_year)
# print("Month:",time_here[1],time_here.tm_mon)
# print("Day:",time_here[2],time_here.tm_mday)
#reaction time game
# import time
# from time import time as my_timer
# import random
#
# input("press enter to start")
# wait_time = random.randint(1,6)
# time.sleep(wait_time)
# start_time=my_timer()
# input("press enter to stop")
# end_time=my_timer()
#
# print(start_time,end_time)
# print("started at "+ time.strftime("%X",time.localtime(start_time)))
# print("Ended at "+ time.strftime("%X",time.localtime(end_time)))
# print("Time taken for response was {}".format(end_time-start_time))
#apart from the time method we also have three other methods that we can make use of
#monotonic - this can be used ,so that even if there is daylight saving time,activates
#in the mean time or the user changes the clock in system,always the end time
#will be higher than the
#start time if we use the monotonic
#other 1 is perf_counter
#and the process_time is the elapsed cpu time for the process
#proposal for python - PEP 0418 can read from there
import time
# # from time import perf_counter as my_timer
# # from time import monotonic as my_timer
# from time import process_time as my_timer
# import random
#
#
# input("press enter to start")
# wait_time = random.randint(1,6)
# time.sleep(wait_time)
# start_time=my_timer()
# input("press enter to stop")
# end_time=my_timer()
#
# print(start_time,end_time)
# print("started at "+ time.strftime("%X",time.localtime(start_time)))
# print("Ended at "+ time.strftime("%X",time.localtime(end_time)))
# print("Time taken for response was {}".format(end_time-start_time))
#info about the each clock
print("time():\t\t\t",time.get_clock_info("time"))
print("monotonic():\t",time.get_clock_info("monotonic"))
print("perf_counter():\t",time.get_clock_info("perf_counter"))
print("process_time():\t",time.get_clock_info("process_time"))
Monday, 26 February 2018
Python date time calendar module - Day 15
Subscribe to:
Posts (Atom)