Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
478 B
5
Indexable
Never
from datetime import datetime
from inspect import formatargspec

def convert2datetime(str, formart):
    date_object = datetime.strptime(str, formart)
    return date_object

def compare(dto1, dto2):
    return dto1 - dto2

if __name__ == "__main__":
    str1 = '09:30 11-05-2022'
    str2 = '09:32 11-05-2022'
    formart = '%H:%M %d-%m-%Y'

    dto1 = convert2datetime(str1, formart)
    dto2 = convert2datetime(str2, formart)

    print(compare(dto1, dto2).total_seconds())