FastDateTimeParser

Ecng.Common

Provides methods to parse and format date and time strings using a fast custom parser.

Constructors

FastDateTimeParser
public FastDateTimeParser(string template)
fastDateTimeParser = FastDateTimeParser(template)

Initializes a new instance of the FastDateTimeParser class with the specified format template.

template
The date and time format template.

Properties

Template
public string Template { get; }
value = fastDateTimeParser.Template

Gets the date and time format template used for parsing and formatting.

Methods

Append
private static void Append(StringBuilder builder, int value, int size)
FastDateTimeParser.Append(builder, value, size)

Appends the specified integer value to the StringBuilder with a given size.

builder
The StringBuilder to append to.
value
The integer value to append.
size
The number of digits to include.
Parse
public DateTime Parse(string input)
result = fastDateTimeParser.Parse(input)

Parses the specified input string into a DateTime based on the predefined template.

input
The string input representing the date and time.

Returns: A DateTime object parsed from the input string.

ParseDto
public DateTimeOffset ParseDto(string input)
result = fastDateTimeParser.ParseDto(input)

Parses the specified input string into a DateTimeOffset based on the predefined template, applying the time zone if specified.

input
The string input representing the date and time with time zone.

Returns: A DateTimeOffset object parsed from the input string.

ToString
public string ToString(DateTime value)
result = fastDateTimeParser.ToString(value)

Converts the specified DateTime to its string representation based on the predefined template.

value
The DateTime value to format.

Returns: A string representation of the date and time.

ToString
public override string ToString()
result = fastDateTimeParser.ToString()

Returns a string representation of the tuple, with values separated by commas.

Returns: A string representing the tuple's values.