Skip to content

Commit

Permalink
#1099: Fix display of start date in advanced search
Browse files Browse the repository at this point in the history
The date widget in the advanced search was displaying a day earlier than
the day it should have. Here is why:
moment/moment#3086
  • Loading branch information
maradragan committed Nov 12, 2018
1 parent 53b8976 commit d7ca8f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions client/src/components/advancedSearch/DateRangeSearch.js
Expand Up @@ -11,6 +11,8 @@ import utils from 'utils'

import {BETWEEN, BEFORE, AFTER, LAST_DAY, LAST_WEEK, LAST_MONTH, RANGE_TYPE_LABELS, dateToQuery, dateRangeStartKey, dateRangeEndKey} from 'dateUtils'

const DATE_FORMAT = 'YYYY-MM-DD'

const dateRangeValue = PropTypes.shape({
relative: PropTypes.string,
start: PropTypes.string,
Expand Down Expand Up @@ -170,8 +172,8 @@ export default class DateRangeSearch extends Component {
const filterValue = {}
if (query[startKey] && query[endKey]) {
filterValue.relative = BETWEEN
filterValue.start = moment(query[startKey]).toISOString()
filterValue.end = moment(query[endKey]).toISOString()
filterValue.start = moment(query[startKey]).format(DATE_FORMAT)
filterValue.end = moment(query[endKey]).format(DATE_FORMAT)
toQueryValue[startKey] = query[startKey]
toQueryValue[endKey] = query[endKey]
}
Expand All @@ -183,12 +185,12 @@ export default class DateRangeSearch extends Component {
}
else {
filterValue.relative = AFTER
filterValue.start = moment(query[startKey]).toISOString()
filterValue.start = moment(query[startKey]).format(DATE_FORMAT)
}
}
else if (query[endKey]) {
filterValue.relative = BEFORE
filterValue.end = moment(query[endKey]).toISOString()
filterValue.end = moment(query[endKey]).format(DATE_FORMAT)
toQueryValue[endKey] = query[endKey]
}
if (Object.keys(filterValue).length) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/rollup/Show.js
Expand Up @@ -198,7 +198,7 @@ class BaseRollupShow extends Page {
<Fieldset title={
<span>
Daily Rollup - {this.dateLongStr}
<CalendarButton onChange={this.changeRollupDate} value={this.state.date.toISOString()} style={calendarButtonCss} />
<CalendarButton onChange={this.changeRollupDate} value={this.state.date.format('YYYY-MM-DD')} style={calendarButtonCss} />
</span>
} action={
<div>
Expand Down

0 comments on commit d7ca8f9

Please sign in to comment.