Skip to content

Commit

Permalink
regione-piemonte#848: Date format in feature grid
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 committed Feb 26, 2021
1 parent a08a2bf commit d9d7982
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/js/components/GridCellDate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const PropTypes = require('prop-types');
*/

const React = require('react');
const DateFormat = require('@mapstore/components/I18N/Date');
const {IntlProvider, FormattedDate} = require('react-intl');

class GridCellDate extends React.Component {
static propTypes = {
Expand All @@ -20,9 +20,10 @@ class GridCellDate extends React.Component {
};

render() {
const locale = this.props.params.colDef.locale || this.context.locale || 'it-IT';
const value = this.props.params.value !== null && this.props.params.value !== undefined && this.props.params.value.indexOf('Z') !== -1 ? this.props.params.value.replace('Z', '') : this.props.params.value;
const date = value !== null ? new Date(value) : null;
return date !== null && !isNaN(date.getTime()) ? (<DateFormat value={date} dateParams={this.props.params.colDef.dateFormat} />) : (<noscript/>);
return date !== null && !isNaN(date.getTime()) ? (<IntlProvider locale={locale}><FormattedDate locales={locale} value={date} {...this.props.params.colDef.dateFormat} /></IntlProvider>) : (<noscript/>);
}
}

Expand Down

0 comments on commit d9d7982

Please sign in to comment.