Skip to main content

DateModal class

Namespace: Arlecchino.Modals.Setting · Assembly: Arlecchino

A calendar date, edited as year, month and day, and kept inside both the bounds and the calendar at every step. A day the new month does not have is pulled back to its last.

public sealed class DateModal : SegmentedModal

Inherits from SegmentedModal

Constructors

MemberSummary
DateModal()

Properties

MemberSummary
MaximumLatest date allowed.
MinimumEarliest date allowed.
OnSubmitCalled with the date that was confirmed.
SegmentCountYear, month and day.
SeparatorSegments are drawn in ISO order, so they are separated by a dash.
ValueThe date as it stands. Defaults to today.

Methods

MemberSummary
Add(int)Steps by whole years, months or days depending on the active segment, so stepping the month at the end of a long month lands on a date the shorter month actually has.
ApplyTypedValue(int, int)Stores a typed segment, pulling impossible input into range: month into 1-12 and day into the days the resulting month has.
Draw(ModalFrame)
SegmentLength(int)Four digits for the year, two for the rest.
SegmentTexts()The date as a four-digit year and two-digit month and day.
Submit()

Constructors in detail

DateModal()

Obsolete

Constructors of types with required members are not supported in this version of your compiler.

public DateModal();

Properties in detail

Maximum

public DateOnly Maximum { get; init; }

Latest date allowed.

Type DateOnly

Minimum

public DateOnly Minimum { get; init; }

Earliest date allowed.

Type DateOnly

OnSubmit

public Action<DateOnly> OnSubmit { get; init; }

Called with the date that was confirmed.

Type Action<T><DateOnly>

SegmentCount

public virtual int SegmentCount { get; }

Year, month and day.

Type int

Separator

public override string Separator { get; }

Segments are drawn in ISO order, so they are separated by a dash.

Type string

Value

public DateOnly Value { get; set; }

The date as it stands. Defaults to today.

Type DateOnly

Methods in detail

Add(int)

public virtual void Add(int delta);

Steps by whole years, months or days depending on the active segment, so stepping the month at the end of a long month lands on a date the shorter month actually has.

Parameters

NameTypeDescription
deltaintHow far to step; negative goes back.

ApplyTypedValue(int, int)

public virtual void ApplyTypedValue(int segment, int value);

Stores a typed segment, pulling impossible input into range: month into 1-12 and day into the days the resulting month has.

Parameters

NameTypeDescription
segmentintIndex of the segment that was typed into.
valueintThe digits, parsed.

Draw(ModalFrame)

public override void Draw(ModalFrame frame);

Parameters

NameTypeDescription
frameModalFrame

SegmentLength(int)

public virtual int SegmentLength(int segment);

Four digits for the year, two for the rest.

Parameters

NameTypeDescription
segmentintIndex of the segment.

Returns int — Its digit count.

SegmentTexts()

public virtual string[] SegmentTexts();

The date as a four-digit year and two-digit month and day.

Returns string[] — One string per segment.

Submit()

public virtual void Submit();