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>)
public static int ConvertToText(this DateTime value, Span<char> result)
Parameters
value
DateTimeThe 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)
public static int ConvertToText(this DateTime value, Span<char> result, int subSecondPrecision)
Parameters
value
DateTimeThe DateTime to convert.
result
Span<char>The target to contain the result of the conversion.
subSecondPrecision
intThe 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
DateTimeThe DateTime to convert.
argument
TThe 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 theaction
.
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
DateTimeThe DateTime to convert.
argument
TThe argument to pass into the
action
.action
ReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
subSecondPrecision
intThe number of digits to display for fractions of a second.
Type Parameters
T
The type of
argument
to pass into theaction
.
Exceptions
- ArgumentNullException
Thrown if
action
is null.