Skip to content

Conversation

@FaustVX
Copy link

@FaustVX FaustVX commented Nov 11, 2025

fixes #1949

  • I have read the Contribution Guidelines
  • I have commented on the issue above and discussed the intended changes
  • A maintainer has signed off on the changes and the issue was assigned to me
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors
  • The documentation was modified to reflect the changes OR no documentation changes are required.

Changes

I've changed the ProgressTask.StartTime & ProgressTask.StopTime properties to long? then use the new API from .NET8: TimeProvider.System.GetTimestamp() & TimeProvider.System.GetElapsedTime()

I've also added Microsoft.Bcl.TimeProvider package for netstandard2.0 because TimeProvider is only available from net8.0

await AnsiConsole.Progress()
    .Columns([
        new TaskDescriptionColumn(),
        new ProgressBarColumn(),
        new ElapsedTimeColumn() { Format = null }, // change the new Format property
    ]).StartAsync(...);

ElepsedTimeColumn.cs & RemainingTimeColumn.cs

public string? Format { get; set; } = @"hh\:mm\:ss";

public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
{
    // ...
    return new Text($"{elapsed.Value.ToString(Format)}", Style ?? Style.Plain);
}

Please upvote 👍 this pull request if you are interested in it.

@FaustVX
Copy link
Author

FaustVX commented Nov 11, 2025

@microsoft-github-policy-service agree

Removed overridden `GetColumnWidth` method, like in `ElapsedTimeColumn`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using the new and more precice TimeProvider for ProgressTask instead of DateTime

1 participant