Skip to content

Commit

Permalink
Add caption to timezones dropdown (#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
danimiba authored Feb 6, 2020
1 parent 4b18e92 commit ea28608
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions locales/template/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@
"The system only accepts CSV files": "",
"This will finalize the survey execution": "",
"Thu": "",
"Time at selected timezone: {{time}}": "",
"Timezone": "",
"Title": "",
"Title must not be blank": "",
Expand Down
12 changes: 10 additions & 2 deletions web/static/js/components/timezones/TimezoneAutocomplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class TimezoneAutocomplete extends Component {
dispatch: PropTypes.func.isRequired,
selectedTz: PropTypes.string,
timezones: PropTypes.object,
readOnly: PropTypes.bool
readOnly: PropTypes.bool,
i18n: PropTypes.object
}

constructor(props) {
Expand Down Expand Up @@ -66,8 +67,14 @@ class TimezoneAutocomplete extends Component {
dispatch(actions.setTimezone(timezone.id))
}

getTimeForTimezone(timezone, locale) {
var date = new Date()
return date.toLocaleString(locale, {timeZone: timezone, hour12: false, hour: '2-digit', minute: '2-digit', weekday: 'long'})
}

render() {
const { timezones, t, readOnly } = this.props
const { timezones, t, readOnly, i18n } = this.props
const currentLanguage = i18n.language

if (!timezones || !timezones.items) {
return (
Expand All @@ -89,6 +96,7 @@ class TimezoneAutocomplete extends Component {
className='timezone-dropdown'
ref='autocomplete'
/>
<span className='small-text-bellow'>{t('Time at selected timezone: {{time}}', {time: this.getTimeForTimezone(this.props.selectedTz, currentLanguage)})}</span>
</div>
)
}
Expand Down

0 comments on commit ea28608

Please sign in to comment.