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
valueDateTimeThe DateTime to convert.
resultSpan<char>The target to contain the result of the conversion.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis 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
valueDateTimeThe DateTime to convert.
resultSpan<char>The target to contain the result of the conversion.
subSecondPrecisionintThe number of digits to display for fractions of a second.
Returns
- int
Returns the number of characters in the result.
Exceptions
- IndexOutOfRangeException
Thrown if
resultis 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
valueDateTimeThe DateTime to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis 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
valueDateTimeThe DateTime to convert.
argumentTThe argument to pass into the
action.actionReadOnlySpanAction<char, T>The action to perform with the resulting ReadOnlySpan<T> of characters.
subSecondPrecisionintThe number of digits to display for fractions of a second.
Type Parameters
TThe type of
argumentto pass into theaction.
Exceptions
- ArgumentNullException
Thrown if
actionis null.