diff --git a/README.md b/README.md index e6cac66..67fe626 100644 --- a/README.md +++ b/README.md @@ -228,19 +228,20 @@ reader = csv.DictReader( total = timedelta(seconds=0) for line in reader: - if not line['end']: - continue - start = datetime.strptime(line['start'], '%Y-%m-%dT%H:%M:%S.%fZ') - end = datetime.strptime(line['end'], '%Y-%m-%dT%H:%M:%S.%fZ') + + if not line['end']: + end = datetime.utcnow() + else: + end = datetime.strptime(line['end'], '%Y-%m-%dT%H:%M:%S.%fZ') total += end - start -hours = ceil(total.total_seconds() / (3600)) +hours = total.total_seconds() / 3600 earnings = hours * config['hourly_rate'] currency = config['currency'] -print(f'You have earned: {earnings} {currency}') +print(f'You have earned: ${earnings:.2f} {currency}') ``` Now if you run `t display -f earnings` you will get something like: