Skip to content
ConsoleMonster
Class

DurationPresenter

ConsoleMonster.Presenters

Namespace
ConsoleMonster.Presenters
Assembly
ConsoleMonster
Implements
ICellPresenter
Modifiers
sealed

A duration in the most readable unit: 380 ms, 4.2 s, 1 m 05 s, 2 h 14 m, 3 d 4 h. Accepts TimeSpan values, or numbers in DurationPresenter.NumberUnit (seconds by default). TimeSpan.MinValue, TimeSpan.MaxValue and numbers outside the TimeSpan range show as a dash.

Inheritance

  • object
  • DurationPresenter

Constructors

public DurationPresenter(TimeSpan? numberUnit = null) #

Creates a duration presenter.

Parameters

numberUnit System.TimeSpan? = null optional
The unit of plain numbers (default seconds).

Methods

public static string Format(TimeSpan span, CultureInfo culture) #

Formats a duration with the culture's decimal separator.

Parameters

span System.TimeSpan required
The duration.
culture System.Globalization.CultureInfo required
The culture.

Returns

string The text.
public PresentedValue Present(object? value, PresenterContext context) #

Presents a value.

Parameters

value object? required
The raw value (may be null).
context ConsoleMonster.Presenters.PresenterContext required
Culture, clock, time zone, column statistics and the render context.

Returns

PresentedValue The presented value.

Properties

public TimeSpan NumberUnit { get; } #

The unit of plain numbers.

public bool Compact { get; set; } #

Use compact units such as 4m 31s while retaining the ordinary formatting by default.