Skip to content

Commit

Permalink
Bug - Fix UTC DateColumn vaue display (#4841)
Browse files Browse the repository at this point in the history
Added toMoment method to allow Moment.js to use utc dates.
Updated getValue to use toMoment for proper output.
  • Loading branch information
alsoicode authored and autoboxer committed Oct 29, 2018
1 parent 2180b7e commit 50b221e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fields/types/date/DateColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ var DateColumn = React.createClass({
data: React.PropTypes.object,
linkTo: React.PropTypes.string,
},
toMoment (value) {
if (this.props.col.field.isUTC) {
return moment.utc(value);
} else {
return moment(value);
}
},
getValue () {
const value = this.props.data.fields[this.props.col.path];
if (!value) return null;

const format = (this.props.col.type === 'datetime') ? 'MMMM Do YYYY, h:mm:ss a' : 'MMMM Do YYYY';
return moment(value).format(format);
return this.toMoment(value).format(format);
},
render () {
const value = this.getValue();
Expand Down

0 comments on commit 50b221e

Please sign in to comment.