Skip to content

Commit

Permalink
fix(ui): fix validation for date props [LN-Zap#3600]
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulbile committed Nov 10, 2020
1 parent fffda3f commit 7099dfa
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions renderer/containers/UI/FormattedDateTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ const mapStateToProps = state => ({
timeDisplayMode: settingsSelectors.currentConfig(state).timeDisplayMode,
})

const FormattedDateTime = ({ timeDisplayMode, format, month = 'long', value }) => {
const hour12 = timeDisplayMode && timeDisplayMode === '12hour' ? 1 : 0
const FormattedDateTime = ({ timeDisplayMode = '12hour', format, month = 'long', value }) => {
const is12Hour = timeDisplayMode === '12hour'

switch (format) {
case 'date':
return <FormattedDate day="2-digit" month={month} value={value} year="numeric" />
case 'time':
return <FormattedTime hour12={hour12} value={value} />
return <FormattedTime hour12={is12Hour} value={value} />
default:
return (
<FormattedDate
day="2-digit"
hour="numeric"
hour12={hour12}
hour12={is12Hour}
minute="numeric"
month={month}
value={value}
Expand All @@ -31,10 +32,10 @@ const FormattedDateTime = ({ timeDisplayMode, format, month = 'long', value }) =
}

FormattedDateTime.propTypes = {
format: PropTypes.string,
format: PropTypes.oneOf(['date', 'time']),
month: PropTypes.string,
timeDisplayMode: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(Date)]).isRequired,
timeDisplayMode: PropTypes.oneOf(['12hour', '24Hour']),
value: PropTypes.any.isRequired,
}

export default connect(mapStateToProps)(FormattedDateTime)

0 comments on commit 7099dfa

Please sign in to comment.