Skip to content

Commit

Permalink
add date_time to unix convert
Browse files Browse the repository at this point in the history
  • Loading branch information
toravest committed Mar 16, 2025
1 parent 6e0a78a commit dbc0fa1
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/my_package/date_to_unix.py
Original file line number Diff line number Diff line change
@@ -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())))




0 comments on commit dbc0fa1

Please sign in to comment.