Skip to content
ConsoleMonster

API Reference

Class

DatePresenter

Namespace ConsoleMonster.Presenters
Assembly ConsoleMonster
Implements
Modifiers sealed

A point in time, absolute (in the presenter's or the context's time zone), relative to now, or both. Accepts DateTime, DateTimeOffset and ISO 8601 strings. PresentedValue.Number is the number of days from now (negative in the past), so tone rules can flag, for example, certificates that expire soon. DateTime.MinValue and DateTime.MaxValue (and values within 14 hours of them) show as "never" with no number.

Inheritance

  • Object
  • DatePresenter

Constructors

public DatePresenter(DateDisplay display = Absolute, String? format = null, TimeZoneInfo? timeZone = null) #

Creates a date presenter.

Parameters

display ConsoleMonster.Presenters.DateDisplay = Absolute optionalposition: 0
Absolute, relative or both (default absolute).
format System.String? = null optionalposition: 1
The absolute format (default yyyy-MM-dd HH:mm).
timeZone System.TimeZoneInfo? = null optionalposition: 2
The time zone for absolute dates, or null for the context's.

Methods

public PresentedValue Present(Object? value, PresenterContext context) #
Returns: PresentedValue

Presents a value.

Parameters

value System.Object? requiredposition: 0
The raw value (may be null).
context ConsoleMonster.Presenters.PresenterContext requiredposition: 1
Culture, clock, time zone, column statistics and the render context.

Returns

The presented value.

public static String Relative(TimeSpan offset) #
Returns: String

Formats an offset from now: just now, 45 s ago, 3 h ago, in 12 d, 2 y ago.

Parameters

offset System.TimeSpan requiredposition: 0
The value minus now.

Returns

The text.

Properties

public DateDisplay Display { get; } #

Absolute, relative or both.

public String Format { get; } #

The absolute format.

public TimeZoneInfo? TimeZone { get; } #

The time zone override, or null.