ant-design-blazor/components/date-picker/internal/DatePickerQuarterPanel.razor
James Yeung 2e727d9f47 fix(module: date-picker): prevent the year out of range (#973)
* fix(module: date-picker): year would out of range

* prevent out of range

* add two methods

* fix(module: datepicker): out of range error

* fix: decadePanel is still out of range

Co-authored-by: 钟迪龙 <musicvs@163.com>
2021-01-14 10:40:34 +08:00

39 lines
1.6 KiB
C#

@namespace AntDesign.Internal
@typeparam TValue
@inherits DatePickerPanelBase<TValue>
@using System.Globalization;
@{
var calendar = CultureInfo.InvariantCulture.Calendar;
DateTime startDate = new DateTime(PickerValue.Year, 1, 1);
const int MAX_ROW = 1;
const int MAX_COL = 4;
}
<div class='@($"{PrefixCls}-panel")'>
<DatePickerTemplate @attributes="GetAttritubes()"
TValue="TValue"
MaxRow="MAX_ROW"
MaxCol="MAX_COL"
ViewStartDate="startDate"
IsInView="date => true"
IsToday="date => DateHelper.IsSameQuarter(date, DatePicker.CurrentDate)"
IsSelected="date => DateHelper.IsSameQuarter(date, Value)"
GetColTitle='date => date.ToString(Locale.Lang.YearFormat, CultureInfo)'
OnValueSelect="date => OnSelectQuarter(date)"
GetNextColValue="date => DateHelper.AddMonthsSafely(date, 3)">
<RenderPickerHeader>
<DatePickerHeader @attributes="GetAttritubes()"
TValue="TValue"
ShowPreChange="@false"
ShowNextChange="@false"
ShowSuperPreChange="@(!(IsRange && PickerIndex == 1))"
ShowSuperNextChange="@(!(IsRange && PickerIndex == 0))" />
</RenderPickerHeader>
<RenderColValue Context="currentColDate">
@DateHelper.GetDayOfQuarter(currentColDate)
</RenderColValue>
</DatePickerTemplate>
</div>