diff --git a/src/my_package/date_to_unix.py b/src/my_package/date_to_unix.py new file mode 100644 index 0000000..cef3b2d --- /dev/null +++ b/src/my_package/date_to_unix.py @@ -0,0 +1,47 @@ +# importing datetime module +import datetime +import time + +start_date = input("Choose a start date (yyyy, mm, dd, hh, mm): ") +end_date = input("Choose an end date (yyyy, mm, dd, hh, mm): ") + +# Variables that splits and assign the start date values +start_date = start_date.split(",") +start_year = int(start_date[0]) +start_month = int(start_date[1]) +start_date = int(start_date[2]) +start_hour = int(start_date[3]) +start_minute = int(start_date[4]) + +# Variables that splits and assign the end date values +end_date = end_date.split(",") +end_year = int(end_date[0]) +end_month = int(end_date[1]) +end_date = int(end_date[2]) +end_hour = int(end_date[3]) +end_minute = int(end_date[4]) + +# Converts start date to unix, and print, with the user input +start_date_unix = datetime.datetime(start_year, start_month, start_date, start_hour, start_minute) + +# Print regular start date +print("date_time =>", start_date_unix) + +# Print unix start date +print("unix_timestamp => ", + (time.mktime(start_date_unix.timetuple()))) + + +# Converts end date to unix, and print, with the user input +end_date_unix = datetime.datetime(end_year, end_month, end_date, end_hour, end_minute) + +# Print regular end date +print("date_time =>", end_date_unix) + +# Print unix end date +print("unix_timestamp => ", + (time.mktime(end_date_unix.timetuple()))) + + + +