Skip to content

Improve formatting of timespans #1503

@jnyrup

Description

@jnyrup

Description

When formatting a TimeSpan we currently combine the second and millisecond parts, such that TimeSpan.FromSeconds(1.5) is formatted as 1.500s.

When the time span is less than 1 second we could improve formatting by outputting the value in milliseconds instead.

Complete minimal example reproducing the issue

Func<Task> act = () => Task.Delay(50.Milliseconds());

await act.Should().CompleteWithinAsync(1.Milliseconds());

Expected behavior:

Expected task to complete within 1ms.

Actual behavior:

Expected task to complete within 0.001s.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions