-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add min to nano converter script
- Loading branch information
Sage Silberman
committed
Feb 16, 2024
1 parent
2c32a99
commit c4ea372
Showing
2 changed files
with
26 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import time | ||
|
||
def convert_to_nanoseconds(minutes_seconds_str): | ||
"""Converts time in MM:SS format to nanoseconds since epoch""" | ||
if minutes_seconds_str is None: | ||
return None | ||
|
||
# Parse minutes:seconds format | ||
minutes, seconds = map(int, minutes_seconds_str.split(':')) | ||
|
||
# Get current time in seconds since epoch | ||
current_time_seconds = int(time.time()) | ||
|
||
# Calculate total seconds since epoch for the given minutes:seconds | ||
total_seconds = current_time_seconds + (minutes * 60) + seconds | ||
|
||
# Convert total seconds to nanoseconds | ||
return total_seconds * 1e9 | ||
|
||
start_MMSS = input("Enter you're starting time value in the format minues:seconds (MM:SS)") | ||
flight_start_ns = convert_to_nanoseconds(start_MMSS) | ||
print("Flight start time in nanoseconds:", flight_start_ns) | ||
|
||
end_MMSS = input("Enter you're ending time value in the format minues:seconds (MM:SS)") | ||
flight_end_ns = convert_to_nanoseconds(end_MMSS) | ||
print("Flight end time in nanoseconds:", flight_end_ns) |