Compare commits
3 Commits
79b1364eb3
...
20a66b8f48
Author | SHA1 | Date | |
---|---|---|---|
20a66b8f48 | |||
59722e19a2 | |||
abf61299a0 |
4
time.txt
Normal file
4
time.txt
Normal file
@ -0,0 +1,4 @@
|
||||
2020-08-12 01:00 Work on Task 1
|
||||
2020-08-12 03:00 Work on Task 2
|
||||
2020-08-16 05:00 Finish Task 2
|
||||
2020-08-31 -08:00 Fee note for August
|
34
tx
Executable file
34
tx
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
import argparse
|
||||
|
||||
# Parse command line arguments
|
||||
parser = argparse.ArgumentParser(description="Description")
|
||||
|
||||
# add arguments to the parser
|
||||
parser.add_argument("-f", "--file")
|
||||
parser.add_argument("mode",
|
||||
help="display the square of a given number",
|
||||
nargs='?', default="total",
|
||||
choices=["total"])
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.file:
|
||||
time_file = open(args.file,'r')
|
||||
else:
|
||||
time_file = open('time.txt','r')
|
||||
|
||||
if args.mode == "total":
|
||||
total_time = timedelta()
|
||||
|
||||
for line in time_file:
|
||||
date_time_description = line.split(" ", 2)
|
||||
|
||||
hours, minutes = date_time_description[1].split(':', 1)
|
||||
delta = timedelta(hours=int(hours), minutes=int(minutes))
|
||||
|
||||
total_time += delta
|
||||
|
||||
print('Total time: ', total_time)
|
Loading…
x
Reference in New Issue
Block a user