Skip to content

Commit

Permalink
Merge pull request #143 from ZeroGachis/feature/add-year-calendar-sup…
Browse files Browse the repository at this point in the history
…port

✨ NumericDateEntry - Support year first calendar
  • Loading branch information
a-bertrand authored Sep 15, 2023
2 parents 427c5fd + 4b1c6ab commit 68a7ed5
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit 68a7ed5

Please sign in to comment.