Closed sanjayankur31 closed 1 year ago
I updated both commits to add a signed off by line.
Btw, when the report is run without arguments, i still see an error. It was meant to be fixed i https://github.com/GothenburgBitFactory/timewarrior/commit/c80442c8786226b5ed4685c4a32e8b0454eaf69c from the looks of it:
$ timew report totals.py
Traceback (most recent call last):
File "/home/asinha/.timewarrior/extensions/totals.py", line 184, in <module>
for line in calculate_totals(sys.stdin):
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/asinha/.timewarrior/extensions/totals.py", line 146, in calculate_totals
"Total by Tag, for {:%Y-%m-%d %H:%M:%S} - {:%Y-%m-%d %H:%M:%S}".format(report_start, report_end),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unsupported format string passed to NoneType.__format__
'/home/asinha/.timewarrior/extensions/totals.py' returned 1 without producing output.
I think it's because report_start
and report_end
can both be None
if temp.report.start
and temp.report.end
aren't included in the config that's passed to the script. New issue for this one (if someone else can confirm it)?
The PR looks good to me now. 👍🏻
Btw, when the report is run without arguments, i still see an error. ... New issue for this one (if someone else can confirm it)?
I confirm this, but we can also fix it right here.
The fix is quite simple, just add the following else
statement after line 102:
diff --git a/ext/totals.py b/ext/totals.py
--- a/ext/totals.py (revision c4bb908bcc021320b502d70b860f5ef853fc7900)
+++ b/ext/totals.py (revision c6c2d1e0cbdccfd8e95deaff8cd7b95a201a6ca1)
@@ -100,6 +100,9 @@
if "start" in j[0]:
if report_start_utc is not None:
j[0]["start"] = max(report_start_utc, datetime.datetime.strptime(j[0]["start"], DATEFORMAT).replace(tzinfo=from_zone)).strftime(DATEFORMAT)
+ else:
+ report_start_utc = datetime.datetime.strptime(j[0]["start"], DATEFORMAT).replace(tzinfo=from_zone)
+ report_start = report_start_utc.astimezone(tz=to_zone)
else:
return ["Cannot display an past open range"]
The case of temp.report.end
being empty is already handled, but there is also a small bug in the time conversion. It has to be
Subject: [PATCH] Fix conversion from UTC to local zone for report end time
---
diff --git a/ext/totals.py b/ext/totals.py
--- a/ext/totals.py (revision 84fdf76f9aba22d9badbcbdf92942714cb5e254f)
+++ b/ext/totals.py (revision c4bb908bcc021320b502d70b860f5ef853fc7900)
@@ -107,7 +107,8 @@
if report_end_utc is not None:
j[-1]["end"] = min(report_end_utc, datetime.datetime.strptime(j[-1]["end"], DATEFORMAT).replace(tzinfo=from_zone)).strftime(DATEFORMAT)
else:
- report_end = datetime.datetime.strptime(j[-1]["end"], DATEFORMAT).replace(tzinfo=from_zone)
+ report_end_utc = datetime.datetime.strptime(j[-1]["end"], DATEFORMAT).replace(tzinfo=from_zone)
+ report_end = report_end_utc.astimezone(tz=to_zone)
else:
if report_end_utc is not None:
j[-1]["end"] = report_end_utc.strftime(DATEFORMAT)
(aligning it also to the handling of temp.report.start
).
Thanks, I've also incorporated your two fixes here now.
Fixes #540