Table of Contents

Class DateTimeToTextConverter

Namespace
Switchboard
Assembly
Switchboard.TextConverter.dll

Converts a DateTime value into a string of characters without allocating memory for garbage collection.

public static class DateTimeToTextConverter
Inheritance
DateTimeToTextConverter

Fields

MaxCharacterCount

Gets the maximum number of characters necessary to represent a DateTime value.

public const int MaxCharacterCount = 27

Methods

ConvertToText(DateTime, Span<char>)

Converts a DateTime value into a Span<T> of characters.

public static int ConvertToText(this DateTime value, Span<char> result)

Parameters

value DateTime

The DateTime to convert.

result Span<char>

The target to contain the result of the conversion.

Returns

int

Returns the number of characters in the result.

Exceptions

IndexOutOfRangeException

Thrown if result is not long enough to hold the value.

ConvertToText(DateTime, Span<char>, int)

Converts a DateTime value into a Span<T> of characters.

public static int ConvertToText(this DateTime value, Span<char> result, int subSecondPrecision)

Parameters

value DateTime

The DateTime to convert.

result Span<char>

The target to contain the result of the conversion.

subSecondPrecision int

The number of digits to display for fractions of a second.

Returns

int

Returns the number of characters in the result.

Exceptions

IndexOutOfRangeException

Thrown if result is not long enough to hold the value.

ConvertToText<T>(DateTime, T, ReadOnlySpanAction<char, T>)

Converts a DateTime value into a ReadOnlySpan<T> of characters, then passes that and the argument into the action.

public static void ConvertToText<T>(this DateTime value, T argument, ReadOnlySpanAction<char, T> action)

Parameters

value DateTime

The DateTime to convert.

argument T

The argument to pass into the action.

action ReadOnlySpanAction<char, T>

The action to perform with the resulting ReadOnlySpan<T> of characters.

Type Parameters

T

The type of argument to pass into the action.

Exceptions

ArgumentNullException

Thrown if action is null.

ConvertToText<T>(DateTime, T, ReadOnlySpanAction<char, T>, int)

Converts a DateTime value into a ReadOnlySpan<T> of characters, then passes that and the argument into the action.

public static void ConvertToText<T>(this DateTime value, T argument, ReadOnlySpanAction<char, T> action, int subSecondPrecision)

Parameters

value DateTime

The DateTime to convert.

argument T

The argument to pass into the action.

action ReadOnlySpanAction<char, T>

The action to perform with the resulting ReadOnlySpan<T> of characters.

subSecondPrecision int

The number of digits to display for fractions of a second.

Type Parameters

T

The type of argument to pass into the action.

Exceptions

ArgumentNullException

Thrown if action is null.