Table of Contents

Class TwDateTimeFormats

Namespace
TwBlazor.Localization
Assembly
TwBlazor.dll

The date and time formats components render with, resolved for one culture from TwDateTimeFormatOptions, the resource files and the culture itself.

public sealed class TwDateTimeFormats
Inheritance
TwDateTimeFormats
Inherited Members

Constructors

TwDateTimeFormats()

public TwDateTimeFormats()

Properties

AmDesignator

Gets the text shown for the morning half of a 12 hour clock.

public string AmDesignator { get; }

Property Value

string

Culture

Gets the culture that supplies month names, day names and AM/PM designators.

public required CultureInfo Culture { get; init; }

Property Value

CultureInfo

DateInput

Gets the format the date pickers type and parse, or null to use the theme's default.

public string? DateInput { get; init; }

Property Value

string

DateTimeInput

Gets the format the date time pickers type and parse, or null to use the theme's default.

public string? DateTimeInput { get; init; }

Property Value

string

FirstDayOfWeek

Gets the day a week starts on.

public required DayOfWeek FirstDayOfWeek { get; init; }

Property Value

DayOfWeek

Hour

Gets or sets the format of an hour label in the calendar's time gutter. Defaults to h tt on a 12 hour clock and HH:mm on a 24 hour one.

public required string Hour { get; init; }

Property Value

string

LongDate

Gets or sets the format of a full date, used for the accessible name of a day. Defaults to the culture's long date pattern.

public required string LongDate { get; init; }

Property Value

string

MediumDate

Gets or sets the format of an abbreviated date. Defaults to d MMM yyyy.

public required string MediumDate { get; init; }

Property Value

string

Month

Gets or sets the format of a month on its own. Defaults to MMMM.

public required string Month { get; init; }

Property Value

string

MonthDay

Gets or sets the format of a day and month without the year. Defaults to d MMM.

public required string MonthDay { get; init; }

Property Value

string

MonthYear

Gets or sets the format of a month and year heading. Defaults to the culture's year month pattern.

public required string MonthYear { get; init; }

Property Value

string

PmDesignator

Gets the text shown for the afternoon half of a 12 hour clock.

public string PmDesignator { get; }

Property Value

string

ShortMonth

Gets or sets the format of an abbreviated month. Defaults to MMM.

public required string ShortMonth { get; init; }

Property Value

string

ShortTime

Gets or sets the format of a time of day, for example HH:mm. Defaults to the culture's short time pattern.

public required string ShortTime { get; init; }

Property Value

string

TimeInput

Gets the format the time pickers type and parse, or null to derive it from the clock style.

public string? TimeInput { get; init; }

Property Value

string

Use12HourClock

Gets whether displayed times use a 12 hour clock.

public required bool Use12HourClock { get; init; }

Property Value

bool

Use12HourInput

Gets whether the time pickers use a 12 hour clock when their Is12HourFormat parameter is not set.

public required bool Use12HourInput { get; init; }

Property Value

bool

WeekdayDay

Gets or sets the format of a week view column heading. Defaults to ddd d.

public required string WeekdayDay { get; init; }

Property Value

string

Year

Gets or sets the format of a year. Defaults to yyyy.

public required string Year { get; init; }

Property Value

string

Methods

Format(DateTime, string)

Formats a date with one of the formats on this object, using Culture.

public string Format(DateTime value, string format)

Parameters

value DateTime

The date to format.

format string

The format string, usually one of this object's properties.

Returns

string

The formatted date.

Format(TimeOnly, string)

Formats a date with one of the formats on this object, using Culture.

public string Format(TimeOnly value, string format)

Parameters

value TimeOnly

The date to format.

format string

The format string, usually one of this object's properties.

Returns

string

The formatted date.

FormatDateTime(DateTime)

Formats a date and time as MediumDate followed by ShortTime.

public string FormatDateTime(DateTime value)

Parameters

value DateTime

The date and time to format.

Returns

string

The formatted date and time, for example 1 Oct 2026 09:05.

GetDayOffset(DayOfWeek)

Gets how many days day is after FirstDayOfWeek (0 to 6), which is the column it sits in on a week grid.

public int GetDayOffset(DayOfWeek day)

Parameters

day DayOfWeek

The day of the week.

Returns

int

The zero based column.

GetStartOfWeek(DateTime)

Gets the first day of the week containing date.

public DateTime GetStartOfWeek(DateTime date)

Parameters

date DateTime

Any date in the week.

Returns

DateTime

Midnight on the week's first day.

GetWeekOfMonth(DateTime)

Gets the 1-based week of the month date falls in, counting the rows of a month grid that starts on FirstDayOfWeek.

public int GetWeekOfMonth(DateTime date)

Parameters

date DateTime

The date to place.

Returns

int

The week of the month, from 1 to 6.

GetWeekdayHeaders()

Gets the shortest weekday names in display order, starting from FirstDayOfWeek.

public IReadOnlyList<string> GetWeekdayHeaders()

Returns

IReadOnlyList<string>

The seven column headings of a week grid.

GetWeekdayNames()

Gets the full weekday names in display order, starting from FirstDayOfWeek.

public IReadOnlyList<string> GetWeekdayNames()

Returns

IReadOnlyList<string>

The seven weekday names.

GetWeekdays()

Gets the days of the week in display order, starting from FirstDayOfWeek.

public IReadOnlyList<DayOfWeek> GetWeekdays()

Returns

IReadOnlyList<DayOfWeek>

The seven days of the week.

Is12HourPattern(string)

Works out whether a time format string describes a 12 hour clock.

public static bool Is12HourPattern(string pattern)

Parameters

pattern string

A .NET time format string.

Returns

bool

true when the pattern has a 12 hour specifier outside quoted text.