Skip to content

Commit

Permalink
#60 Start week from sunday for "en" locale (#61)
Browse files Browse the repository at this point in the history
Subscribe to this issue to remove ternary operators after it will be
fixed

iamkun/dayjs#215

Bugfixes
=====

Start week from sunday for "en" locale
  • Loading branch information
kvolkovich-sc authored Aug 6, 2018
1 parent 9cc8392 commit 93144a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/client/components/DateInput/DateInput.DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Based on configured to OpusCapita defaults [react-day-picker](https://github.com
<DateInput
value={_scope.state.value}
dateFormat="dd/MM/yyyy"
disabled={true}
disabled={false}
locale="en"
onChange={_scope.handleChange}
/>
Expand Down
18 changes: 15 additions & 3 deletions src/client/components/DateRangeInput/DateRangeInput.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,35 @@ let defaultProps = {
variants: [
{
getLabel: (locale) => getMessage(locale, 'previousWeek'),
getValue: (locale) => [
// TODO remove ternary operator below. Monitor this issue: https://github.com/iamkun/dayjs/issues/215
getValue: (locale) => locale === 'en' ? [
dayjs().locale(locale).subtract(7, 'days').startOf('week').toDate(),
dayjs().locale(locale).subtract(7, 'days').endOf('week').toDate()
] : [
dayjs().locale(locale).subtract(7, 'days').startOf('week').add(1, 'day').toDate(),
dayjs().locale(locale).subtract(7, 'days').endOf('week').add(1, 'day').toDate()
]
},
{
getLabel: (locale) => getMessage(locale, 'thisWeek'),
getValue: (locale) => [
// TODO remove ternary operator below. Monitor this issue: https://github.com/iamkun/dayjs/issues/215
getValue: (locale) => locale === 'en' ? [
dayjs().locale(locale).startOf('week').toDate(),
dayjs().locale(locale).endOf('week').toDate()
] : [
dayjs().locale(locale).startOf('week').add(1, 'day').toDate(),
dayjs().locale(locale).endOf('week').add(1, 'day').toDate()
]
},
{
getLabel: (locale) => getMessage(locale, 'nextWeek'),
getValue: (locale) => [
// TODO remove ternary operator below. Monitor this issue: https://github.com/iamkun/dayjs/issues/215
getValue: (locale) => locale === 'en' ? [
dayjs().locale(locale).add(7, 'days').startOf('week').toDate(),
dayjs().locale(locale).add(7, 'days').endOf('week').toDate()
] : [
dayjs().locale(locale).add(7, 'days').startOf('week').add(1, 'day').toDate(),
dayjs().locale(locale).add(7, 'days').endOf('week').add(1, 'day').toDate()
]
},
{
Expand Down
1 change: 1 addition & 0 deletions src/client/components/DayPicker/DayPicker.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class DayPicker extends Component {
className={pickerClassName}
localeUtils={localeUtils}
locale={locale}
firstDayOfWeek={locale === 'en' ? 0 : 1}
onDayClick={this.handleDateChange}
onDayKeyDown={this.handleDateChange}
onDayTouchEnd={this.handleDateChange}
Expand Down

0 comments on commit 93144a6

Please sign in to comment.