diff --git a/core/src/components/datetime/datetime.scss b/core/src/components/datetime/datetime.scss index ce8438b6db1..b03b0c01d9b 100644 --- a/core/src/components/datetime/datetime.scss +++ b/core/src/components/datetime/datetime.scss @@ -48,6 +48,35 @@ opacity: 1; } +/** + * Changing the physical order of the + * picker columns in the DOM is added + * work, so we just use `order` instead. + * + * The picker automatically configures + * the text alignment, so when switching + * the order we need to manually switch + * the text alignment too. + */ +:host .datetime-year .order-month-first .month-column { + order: 1; +} + +:host .datetime-year .order-month-first .year-column { + order: 2; +} + +:host .datetime-year .order-year-first .month-column { + order: 2; + + text-align: end; +} + +:host .datetime-year .order-year-first .year-column { + order: 1; + + text-align: start; +} // Calendar // ----------------------------------- diff --git a/core/src/components/datetime/datetime.tsx b/core/src/components/datetime/datetime.tsx index 1f9ef3f15b1..2c71c5e2bdc 100644 --- a/core/src/components/datetime/datetime.tsx +++ b/core/src/components/datetime/datetime.tsx @@ -32,7 +32,8 @@ import { getMonthAndYear } from './utils/format'; import { - is24Hour + is24Hour, + isMonthFirstLocale } from './utils/helpers'; import { calculateHourFromAMPM, @@ -1097,25 +1098,31 @@ export class Datetime implements ComponentInterface { } private renderYearView() { - const { presentation, workingParts } = this; + const { presentation, workingParts, locale } = this; const calendarYears = getCalendarYears(this.todayParts, this.minParts, this.maxParts, this.parsedYearValues); const showMonth = presentation !== 'year'; const showYear = presentation !== 'month'; - const months = getPickerMonths(this.locale, workingParts, this.minParts, this.maxParts, this.parsedMonthValues); + const months = getPickerMonths(locale, workingParts, this.minParts, this.maxParts, this.parsedMonthValues); const years = calendarYears.map(year => { return { text: `${year}`, value: year } }) + const showMonthFirst = isMonthFirstLocale(locale); + const columnOrder = showMonthFirst ? 'month-first' : 'year-first'; return (