Created
April 11, 2025 08:31
-
-
Save sebastian-berlin-wmse/5bf884e9e2771b6a713fdcf9d1278867 to your computer and use it in GitHub Desktop.
Calculate difference between two timestamps
This file contains hidden or 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
#! /usr/bin/env python | |
"""Calculate time difference between two timestamps | |
First argument is the "from" time and second is the "to" time. Format should | |
be anything that works with `datetime.fromisoformat` | |
(https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat). | |
""" | |
from datetime import datetime | |
import sys | |
from_time = datetime.fromisoformat(sys.argv[1]) | |
to_time = datetime.fromisoformat(sys.argv[2]) | |
print(to_time - from_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment