Skip to content
ConsoleMonster

API Reference

Class

NumberFormat

Namespace ConsoleMonster.Widgets
Assembly ConsoleMonster
Modifiers static

Compact, invariant formatting for numbers, percentages and durations used across widgets.

Inheritance

  • Object
  • NumberFormat

Methods

public static String Clock(TimeSpan elapsed, Boolean shortForm = false) #
Returns: String

Formats a clock: 00:01:23 (or 01:23 under an hour when shortForm is true).

Parameters

elapsed System.TimeSpan requiredposition: 0
The elapsed time.
shortForm System.Boolean = false optionalposition: 1
Whether to drop the hours when zero.

Returns

The text.

public static String Compact(Double value) #
Returns: String

Formats a count compactly: 950, 1.2k, 12k, 1.4M. NaN and infinities give "-".

Parameters

value System.Double requiredposition: 0
The value.

Returns

The text.

public static String Duration(TimeSpan duration) #
Returns: String

Formats a duration compactly: 850ms, 12.4s, 1m 12s, 1h 02m.

Parameters

duration System.TimeSpan requiredposition: 0
The duration.

Returns

The text.

public static String Grouped(Double value) #
Returns: String

Formats a number with thousands separators: 12,345. NaN and infinities give "-".

Parameters

value System.Double requiredposition: 0
The value.

Returns

The text.

public static Boolean IsFinite(Double value) #
Returns: Boolean

Whether a value is a real number (not NaN or an infinity).

Parameters

value System.Double requiredposition: 0
The value.

Returns

True when finite.

public static String Missing(GlyphTier tier) #
Returns: String

The text for a number that has no meaningful display (NaN, infinity): an em dash, or "-" in the ASCII tier.

Parameters

tier ConsoleMonster.Capabilities.GlyphTier requiredposition: 0
The glyph tier.

Returns

The dash.

public static String Percent(Double fraction) #
Returns: String

Formats a fraction (0-1) as a whole percentage: 64%.

Parameters

fraction System.Double requiredposition: 0
The fraction.

Returns

The text.

public static Double PositiveOrZero(Double value) #
Returns: Double

The value when it is finite and positive, otherwise 0 (for scales, totals and segment widths).

Parameters

value System.Double requiredposition: 0
The value.

Returns

The usable magnitude.

public static String Remaining(TimeSpan remaining) #
Returns: String

A time left, rounded up: 12s under a minute, otherwise as NumberFormat.Duration (3m 05s).

Parameters

remaining System.TimeSpan requiredposition: 0
The time left.

Returns

The text.