Skip to content

Commit

Permalink
fix: csvstat no longer errors when a column is a time delta and --jso…
Browse files Browse the repository at this point in the history
…n is set, closes #1247
  • Loading branch information
jpmckinney committed May 22, 2024
1 parent b36512a commit f73742f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Unreleased
----------

- fix: :doc:`/scripts/csvstat` no longer errors when a column is a time delta and :code:`--json` is set.

2.0.0 - May 1, 2024
-------------------

Expand Down
2 changes: 2 additions & 0 deletions csvkit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ def default_str_decimal(obj):


def default_float_decimal(obj):
if isinstance(obj, datetime.timedelta):
return obj.total_seconds()
if isinstance(obj, decimal.Decimal):
return float(obj)
return default_str_decimal(obj)
Expand Down

0 comments on commit f73742f

Please sign in to comment.