Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ NumericDateEntry - Support year first calendar #143

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Smartway.UiComponent/Inputs/NumericDateEntry.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ protected virtual void SetFilledDate()

private void SetEntriesPosition()
{
if (IsDayMonthCalendar())
if (IsDayMonthCalendar() || IsYearsFirstCalendar())
{
DayEntry = FirstEntry;
MonthEntry = SecondEntry;
Expand Down Expand Up @@ -205,7 +205,7 @@ private bool DateTimeIsNull(DateTime date)

private void SetDefaultPlaceholder()
{
if (IsDayMonthCalendar())
if (IsDayMonthCalendar() || IsYearsFirstCalendar())
{
DayEntry.Placeholder = "JJ";
MonthEntry.Placeholder = "MM";
Expand All @@ -226,6 +226,13 @@ private bool IsDayMonthCalendar()
return calendarType.IndexOf("d") < calendarType.IndexOf("M");
}

private bool IsYearsFirstCalendar()
{
var calendarType =
CultureInfo.GetCultureInfo(CultureInfo.CurrentCulture.Name).DateTimeFormat.YearMonthPattern;
return calendarType.IndexOf("y") < calendarType.IndexOf("M");
}

private void OnFocusedSelectAllEntryContent(object sender, FocusEventArgs e)
{
var entry = sender as Entry;
Expand Down
Loading