InputDateTime<TValue> Class

An input component for editing date and time values using the HTML datetime-local input type.

public class InputDateTime<TValue> : InputDate<TValue>

Type parameters

TValue
The type of the value. Supported types are DateTime, DateTimeOffset, and their nullable variants.
Inheritance
InputDate<TValue> InputDateTime<TValue>

Constructors

NameDescription
InputDateTime()

InputDateTime()

public InputDateTime()

No documentation is available.

Properties

NameDescription
OffsetGets or sets the UTC offset to apply when the bound value is a DateTimeOffset. An HTML datetime-local input carries no timezone, so without this the offset of the machine running the component is used, which is the server's offset under Blazor Server rather than the user's. Use TimeZoneService to obtain the user's offset.

Gets or sets the UTC offset to apply when the bound value is a DateTimeOffset. An HTML datetime-local input carries no timezone, so without this the offset of the machine running the component is used, which is the server's offset under Blazor Server rather than the user's. Use TimeZoneService to obtain the user's offset.

public TimeSpan? Offset { get; set; }

Property value

TimeSpan?

Methods

NameDescription
BuildRenderTree(RenderTreeBuilder)Renders the component to the supplied RenderTreeBuilder.
FormatValueAsString(TValue?)Formats the value as a string. Derived classes can override this to determine the formatting used for InputBase<TValue>.CurrentValueAsString.
TryParseValueFromString(string?, TValue, string?)Parses a string to create an instance of TValue. Derived classes can override this to change how InputBase<TValue>.CurrentValueAsString interprets incoming values.

BuildRenderTree(RenderTreeBuilder)

InputDatetime.cs

Renders the component to the supplied RenderTreeBuilder.

protected override void BuildRenderTree(RenderTreeBuilder builder)

Parameters

builder RenderTreeBuilder
A RenderTreeBuilder that will receive the render output.

FormatValueAsString(TValue?)

InputDatetime.cs

Formats the value as a string. Derived classes can override this to determine the formatting used for InputBase<TValue>.CurrentValueAsString.

protected override string FormatValueAsString(TValue? value)

Parameters

value TValue?
The value to format.

Returns

string A string representation of the value.

TryParseValueFromString(string?, TValue, string?)

InputDatetime.cs

Parses a string to create an instance of TValue. Derived classes can override this to change how InputBase<TValue>.CurrentValueAsString interprets incoming values.

protected override bool TryParseValueFromString(string? value, out TValue result, out string? validationErrorMessage)

Parameters

value string?
The string value to be parsed.
result TValue
An instance of TValue.
validationErrorMessage string?
If the value could not be parsed, provides a validation error message.

Returns

bool True if the value could be parsed; otherwise false.