Skip to content

Commit 771b14f

Browse files
committed
Formatted string output. Normalize dates to 12:00 UTC.
1 parent 1aaef95 commit 771b14f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,12 @@ exports.default = _react2.default.createClass({
212212
},
213213
makeDateValues: function makeDateValues(isoString) {
214214
var displayDate = void 0;
215-
var selectedDate = isoString ? new Date(isoString) : null;
215+
var selectedDate = isoString ? new Date(isoString.slice(0, 10) + 'T12:00:00.000Z') : null;
216216
var inputValue = isoString ? this.makeInputValueString(selectedDate) : null;
217217
if (selectedDate) {
218218
displayDate = new Date(selectedDate);
219219
} else {
220-
displayDate = new Date();
221-
displayDate.setHours(12);
222-
displayDate.setMinutes(0);
223-
displayDate.setSeconds(0);
224-
displayDate.setMilliseconds(0);
220+
displayDate = new Date(new Date().toISOString().slice(0, 10) + 'T12:00:00.000Z');
225221
}
226222
return {
227223
value: selectedDate ? selectedDate.toISOString() : null,
@@ -462,7 +458,7 @@ exports.default = _react2.default.createClass({
462458
)
463459
),
464460
_react2.default.createElement('div', { ref: 'overlayContainer' }),
465-
_react2.default.createElement('input', { ref: 'hiddenInput', type: 'hidden', id: this.props.id, name: this.props.name, value: this.state.value || '' }),
461+
_react2.default.createElement('input', { ref: 'hiddenInput', type: 'hidden', id: this.props.id, name: this.props.name, value: this.state.value || '', 'data-formattedvalue': this.state.value ? this.state.inputValue : '' }),
466462
this.props.showClearButton && _react2.default.createElement(
467463
_reactBootstrap.InputGroup.Addon,
468464
{ onClick: this.props.disabled ? null : this.clear, style: { cursor: this.state.inputValue && !this.props.disabled ? "pointer" : "not-allowed" } },

0 commit comments

Comments
 (0)