Skip to content

Commit

Permalink
fix negative time
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Jul 29, 2023
1 parent 293be90 commit 368e8ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed Text.expand_tabs not expanding spans.
- Fixed TimeElapsedColumn from showing negative.

### Added

Expand Down
5 changes: 1 addition & 4 deletions rich/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def render(self, task: "Task") -> Text:
elapsed = task.finished_time if task.finished else task.elapsed
if elapsed is None:
return Text("-:--:--", style="progress.elapsed")
delta = timedelta(seconds=int(elapsed))
delta = timedelta(seconds=max(0, int(elapsed)))
return Text(str(delta), style="progress.elapsed")


Expand Down Expand Up @@ -710,7 +710,6 @@ def __init__(
table_column: Optional[Column] = None,
show_speed: bool = False,
) -> None:

self.text_format_no_percentage = text_format_no_percentage
self.show_speed = show_speed
super().__init__(
Expand Down Expand Up @@ -1636,7 +1635,6 @@ def remove_task(self, task_id: TaskID) -> None:


if __name__ == "__main__": # pragma: no coverage

import random
import time

Expand Down Expand Up @@ -1689,7 +1687,6 @@ def remove_task(self, task_id: TaskID) -> None:
console=console,
transient=False,
) as progress:

task1 = progress.add_task("[red]Downloading", total=1000)
task2 = progress.add_task("[green]Processing", total=1000)
task3 = progress.add_task("[yellow]Thinking", total=None)
Expand Down

0 comments on commit 368e8ad

Please sign in to comment.