Skip to content

Commit

Permalink
changes function, standardvalue for hour and minute, if no input
Browse files Browse the repository at this point in the history
  • Loading branch information
torave committed Apr 7, 2025
1 parent 5094b7e commit 9df86ae
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/my_package/date_to_unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,32 @@ def get_unix_timestamp():
start_year = int(start_date_components[0])
start_month = int(start_date_components[1])
start_date = int(start_date_components[2])
start_hour = int(start_date_components[3])
start_minute = int(start_date_components[4])

# Checks if hour and minute is inputed, if not value = 0
if len(start_date_components) > 3:
start_hour = int(start_date_components[3])
else:
start_hour = 00
if len(start_date_components) > 4:
start_minute = int(start_date_components[4])
else:
start_minute = 00

# Variables that splits and assign the end date values
end_date_components = end_date_input.split(",")
end_year = int(end_date_components[0])
end_month = int(end_date_components[1])
end_date = int(end_date_components[2])
end_hour = int(end_date_components[3])
end_minute = int(end_date_components[4])

# Checks if hour and minute is inputed, if not value = 0
if len(end_date_components) > 3:
end_hour = int(end_date_components[3])
else:
end_hour = 00
if len(end_date_components) > 4:
end_minute = int(end_date_components[4])
else:
end_minute = 00

# Converts dates to timestamp used to convert to unix, and print, with the user input
start_date_timestamp = datetime.datetime(start_year, start_month, start_date, start_hour, start_minute)
Expand Down

0 comments on commit 9df86ae

Please sign in to comment.